function encode_url in Feeds Image Grabber 7
This function encodes URL to form a URL which is properly percent encoded to replace disallowed characters.
RFC3986 specifies the allowed characters in the URL as well as reserved characters in the URL. This function replaces all the disallowed characters in the URL with their repective percent encodings. Already encoded characters are not encoded again, such as '%20' is not encoded to '%2520'.
Parameters: url the url to encode.
Return values: Returns the encoded URL string.
2 calls to encode_url()
- feeds_imagegrabber_feeds_set_target in ./
feeds_imagegrabber.module - Callback for mapping. Here is where the actual mapping happens.
- feeds_imagegrabber_scrape_images in ./
feeds_imagegrabber.module - Scrape images from HTML/XML content.
2 string references to 'encode_url'
- feeds_imagegrabber_feeds_set_target in ./
feeds_imagegrabber.module - Callback for mapping. Here is where the actual mapping happens.
- feeds_imagegrabber_scrape_images in ./
feeds_imagegrabber.module - Scrape images from HTML/XML content.
File
- libraries/
url_to_absolute.inc, line 424 - Converts a relative URL to absolute URL.
Code
function encode_url($url) {
$reserved = array(
":" => '!%3A!ui',
"/" => '!%2F!ui',
"?" => '!%3F!ui',
"#" => '!%23!ui',
"[" => '!%5B!ui',
"]" => '!%5D!ui',
"@" => '!%40!ui',
"!" => '!%21!ui',
"\$" => '!%24!ui',
"&" => '!%26!ui',
"'" => '!%27!ui',
"(" => '!%28!ui',
")" => '!%29!ui',
"*" => '!%2A!ui',
"+" => '!%2B!ui',
"," => '!%2C!ui',
";" => '!%3B!ui',
"=" => '!%3D!ui',
"%" => '!%25!ui',
);
$url = rawurlencode($url);
$url = preg_replace(array_values($reserved), array_keys($reserved), $url);
return $url;
}