Re: Parsing HTML href-Attribute
| From: | Benjamin Hawkes-Lewis | Date: | Mon, 19 Jan 2009 02:22:51 +0000 |
| Subject: | Re: Parsing HTML href-Attribute | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286636@lists.php.net to get a copy of this message | ||
On 16/1/09 23:41, Shawn McKenzie wrote:
Again, I say that it won't work on URLs with spaces, like "my web page.html". When I get a minute I'll fix it. I thought spaces in URLs weren't valid markup, but it seems to validate.Some small points of information: An HTML4 validator will only check that a HREF value is CDATA, as required by the DTD: http://www.w3.org/TR/REC-html40/struct/links.html#adef-href http://www.w3.org/TR/REC-html40/sgml/dtd.html#URI http://www.w3.org/TR/REC-html40/types.html#type-cdata Plenty of things can be CDATA without being a valid URI: http://gbiv.com/protocols/uri/rfc/rfc3986.html Space characters (U+0020) that are not percent encoded are not valid in a URI: http://gbiv.com/protocols/uri/rfc/rfc3986.html#collected-abnf That's not to say that browsers haven't developed error handling for space characters (and other illegal characters) in HREF values. The HTML5 draft proposes an algorithm for parsing and resolving HREF values that includes such error handling: http://www.whatwg.org/specs/web-apps/current-work/#parsing-urls http://www.whatwg.org/specs/web-apps/current-work/#resolving-urls -- Benjamin Hawkes-Lewis