REGRESSION (r127277): CSS URIs with multi-byte Unicode escape sequences fail to parse
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2013 18:26:18 +0000 (18:26 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2013 18:26:18 +0000 (18:26 +0000)
commitba48f3f515a41c08908b394b9c821f19409d8f56
tree2b1b9c878c3c9983a8bf574b6595f266653a4878
parent5529929c5036acfbd4e08e2b2fa188f72ab3e821
REGRESSION (r127277): CSS URIs with multi-byte Unicode escape sequences fail to parse
https://bugs.webkit.org/show_bug.cgi?id=112436

Reviewed by Michael Saboff.

Source/WebCore:

r127277 modified the CSS parser to use 8-bit strings when possible.
However, it failed to handle URIs that contain Unicode escape sequences
that expand to multi-byte characters. Not only would the URI fail to
parse, but so would the remainder of the input string.

Fix this by producing a 16-bit result when we detect a URI with a
multi-byte Unicode escape, like we do for identifiers and other strings.

Test: fast/css/url-with-multi-byte-unicode-escape.html

* css/CSSParser.cpp:
(WebCore::checkAndSkipString): Changed to be a free function since it
doesn't access CSSParser's internal state.
(WebCore::CSSParser::findURI): Added a function that consolidates the
logic of finding the start and end pointers of the URI and the quote
character (if encountered), starting at the current character.
(WebCore::CSSParser::parseURIInternal): Removed duplicated logic for
finding the URI bounds (this now lives in findURI()) and logic for
setting the token type and updating the current character (this now
lives in parseURI()).
(WebCore::CSSParser::parseURI): Find the URI and parse it. If a
multi-byte Unicode escape is encountered, rewind to the beginning of
the URI and re-parse with a 16-bit string as the destination.
* css/CSSParser.h:

LayoutTests:

* fast/css/url-with-multi-byte-unicode-escape-expected.txt: Added.
* fast/css/url-with-multi-byte-unicode-escape.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@145924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css/url-with-multi-byte-unicode-escape-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/url-with-multi-byte-unicode-escape.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h