Reputation: 725
I'm using libcurl to provide HTTP GET and PUT requests request contains login, password and some additional information.
Password contains @ symbol - 1qa@WS#ED The query is created in the following way
snprintf(api_req, sizeof(api_req), "http://%s:%s@%s/export?uuid=%s",\
XEN.user_name,XEN.user_passwd, XEN.host_ip, BACKUP_TASK.vm_uuid)
http://root:1qa@WS#[email protected]/export?uuid=4851501f-82d5-cb73-3158-175cffbbf848
Off course this request will fail as @ shoul be converted to %40, also for ':', dot, percent symbol etc But this is OK password for any OS and user account. What is the best way for handling such issues? Parsing string symbol per symbol with replacemnents seems not very effective. I'm using plain C
Upvotes: 0
Views: 200
Reputation: 50643
Use curl_easy_escape() to escape the characters on your password.
Upvotes: 2