note 95785 added to function.rawurlencode

From: Date: Thu, 21 Jan 2010 22:22:08 +0000
Subject: note 95785 added to function.rawurlencode
Groups: php.notes 
Request: Send a blank email to php-notes+get-165180@lists.php.net to get a copy of this message
Here's a slightly improved version of the above code. An incorrect URI like http://www.skyrock.com/1234/foo&bar.html gets rewritten as: http://www.skyrock.com/1234/foo%26bar.html function _cb_clean_uri_path_component($prx) { $component = $prx[1]; return '/' . rawurlencode($component); } function uri_clean($uri) { $matches = NULL; if (empty($uri)) { return $uri; } $ta = parse_url($uri); if (empty($ta)) { return $uri; } $scheme = $host = $path = $query = $fragment = ''; if (!empty($ta['scheme'])) { $scheme = $ta['scheme'] . '://'; } if (!empty($ta['host'])) { $host = $ta['host']; } if (!empty($ta['path'])) { $path = $ta['path']; } if (!empty($ta['query'])) { $query = '?' . $ta['query']; } if (!empty($ta['fragment'])) { $fragment = '#' . $ta['fragment']; } $fixed_path = preg_replace_callback('£/([^/?]+)£Dus', '_cb_clean_uri_path_component', $path); $clean_uri = $scheme . $host . $fixed_path . $query . $fragment; return $clean_uri; } ---- Server IP: 69.147.83.197 Probable Submitter: 82.224.188.215 ---- Manual Page -- http://www.php.net/manual/en/function.rawurlencode.php Edit -- https://master.php.net/note/edit/95785 Del: integrated -- https://master.php.net/note/delete/95785/integrated Del: useless -- https://master.php.net/note/delete/95785/useless Del: bad code -- https://master.php.net/note/delete/95785/bad+code Del: spam -- https://master.php.net/note/delete/95785/spam Del: non-english -- https://master.php.net/note/delete/95785/non-english Del: in docs -- https://master.php.net/note/delete/95785/in+docs Del: other reasons-- https://master.php.net/note/delete/95785 Reject -- https://master.php.net/note/reject/95785 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165180) next »