[development] URL encoding

CM Lubinski cmc333333 at gmail.com
Sat Mar 13 18:42:49 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> There's an old quote [1] that seems somewhat apt here:
>
>> Some people, when confronted with a problem, think "“I know, I'll use
>> regular expressions."”   Now they have two problems.
>

+1

Scott is completely correct. If you want this to be sane to any degree,
you'll need to parse the url into its components before trying to escape
anything. Once you know which parts map to the components found in
parse_url(), you can apply the appropriate escape rules (such as
url_encode()) to the them individual. From *there* you should build up
the final, escaped url in the form $scheme . '://' . $host . '/' . $path
. '?' . $query

CM Lubinski
http://cmlubinski.info
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLm9yofzi1OiZiJLARAmiuAJ9YpTTIJmXI+eQFm7GraWBRmjEuvgCcDtkw
wykkezVvS9PUsbebUT8n2v0=
=KBjn
-----END PGP SIGNATURE-----


More information about the development mailing list