php - curl_multi "Illegal characters found in URL" php - curl_multi "Illegal characters found in URL" curl curl

php - curl_multi "Illegal characters found in URL"


A quick search of the cURL source code reveals that this error comes from the fact that the URL being supplied to CURLOPT_URL contains the characters \r and/or \n.

From lib/url.c:

  /* We might pass the entire URL into the request so we need to make sure   * there are no bad characters in there.*/  if(strpbrk(data->change.url, "\r\n")) {    failf(data, "Illegal characters found in URL");    return CURLE_URL_MALFORMAT;  }

You should run the URL through $url = trim($url); since there is probably a remaining \r or \n on the end of the URL.