- Revision
- 125878
- Author
- [email protected]
- Date
- 2012-08-17 03:46:46 -0700 (Fri, 17 Aug 2012)
Log Message
View source doesn't interpret escape characters in hrefs.
https://bugs.webkit.org/show_bug.cgi?id=94216
Patch by Anthony Berent <[email protected]> on 2012-08-17
Reviewed by Adam Barth.
Source/WebCore:
The cause was that HTMLViewSourceDocument was passing the unparsed content of the href attribute to the DOM as the URL for the link.
The fix is to pass the parsed content of the href attribute to the DOM.
Test: fast/forms/frames/viewsource-link-on-href-value.html extended to test this case.
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::processTagToken): Pass parsed URL to AddRange.
(WebCore::HTMLViewSourceDocument::addRange):Added argument for parsed URL, and used this instead of text, to create link.
* html/HTMLViewSourceDocument.h:
(HTMLViewSourceDocument): Add new link argument to addRange for parsed URL, defaulting to "".
LayoutTests:
Extra href added to test containing escape characters
* fast/frames/resources/viewsource-frame-3.html: Added href containing escape characters to test
* fast/frames/resources/viewsource-frame-4.html: Added href containing escape characters to test
* fast/frames/viewsource-link-on-href-value.html: Check escape characters are correctly interpreted in href.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (125877 => 125878)
--- trunk/LayoutTests/ChangeLog 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/LayoutTests/ChangeLog 2012-08-17 10:46:46 UTC (rev 125878)
@@ -1,3 +1,16 @@
+2012-08-17 Anthony Berent <[email protected]>
+
+ View source doesn't interpret escape characters in hrefs.
+ https://bugs.webkit.org/show_bug.cgi?id=94216
+
+ Reviewed by Adam Barth.
+
+ Extra href added to test containing escape characters
+
+ * fast/frames/resources/viewsource-frame-3.html: Added href containing escape characters to test
+ * fast/frames/resources/viewsource-frame-4.html: Added href containing escape characters to test
+ * fast/frames/viewsource-link-on-href-value.html: Check escape characters are correctly interpreted in href.
+
2012-08-17 Yoshifumi Inoue <[email protected]>
[Tests] time-multiple-fields-appearance-basic.html and time-multiple-fields-appearance-pseudo-elements.html are failed on Chromium Windows
Modified: trunk/LayoutTests/fast/frames/resources/viewsource-frame-3.html (125877 => 125878)
--- trunk/LayoutTests/fast/frames/resources/viewsource-frame-3.html 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/LayoutTests/fast/frames/resources/viewsource-frame-3.html 2012-08-17 10:46:46 UTC (rev 125878)
@@ -2,5 +2,6 @@
<body>
<a href=""
<a href=""
-<a href=""
+<a href=""
+<a href=""
</body>
Modified: trunk/LayoutTests/fast/frames/resources/viewsource-frame-4.html (125877 => 125878)
--- trunk/LayoutTests/fast/frames/resources/viewsource-frame-4.html 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/LayoutTests/fast/frames/resources/viewsource-frame-4.html 2012-08-17 10:46:46 UTC (rev 125878)
@@ -2,5 +2,6 @@
<BODY>
<A HREF=""
<A HREF=""
-<A HREF=""
+<A HREF=""
+<A HREF=""
</BODY>
Modified: trunk/LayoutTests/fast/frames/viewsource-link-on-href-value.html (125877 => 125878)
--- trunk/LayoutTests/fast/frames/viewsource-link-on-href-value.html 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/LayoutTests/fast/frames/viewsource-link-on-href-value.html 2012-08-17 10:46:46 UTC (rev 125878)
@@ -17,11 +17,16 @@
[ "bar", "http://example.org/foo/bar" ],
[ "/bar", "http://example.org/bar" ],
// This shouldn't be affected.
- [ "http://example.org/foobar", "http://example.org/foobar" ]
+ [ "http://example.org/foobar", "http://example.org/foobar" ],
+ // We should interpret escape chars in the href.
+ // Note that innerHTML escapes '&'s (and other special characters) so
+ // this is saying we expect the text of the href to be "bar?a&b"
+ // and the URL to be "http://example.org/foo/bar?a&b"
+ [ "bar?a&amp;b", "http://example.org/foo/bar?a&b" ]
];
var elements = frame.contentDocument.documentElement.getElementsByTagName("a");
- if (!elements || elements.length !== 4) {
+ if (!elements || elements.length !== 5) {
return false;
}
Modified: trunk/Source/WebCore/ChangeLog (125877 => 125878)
--- trunk/Source/WebCore/ChangeLog 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/Source/WebCore/ChangeLog 2012-08-17 10:46:46 UTC (rev 125878)
@@ -1,3 +1,21 @@
+2012-08-17 Anthony Berent <[email protected]>
+
+ View source doesn't interpret escape characters in hrefs.
+ https://bugs.webkit.org/show_bug.cgi?id=94216
+
+ Reviewed by Adam Barth.
+
+ The cause was that HTMLViewSourceDocument was passing the unparsed content of the href attribute to the DOM as the URL for the link.
+ The fix is to pass the parsed content of the href attribute to the DOM.
+
+ Test: fast/forms/frames/viewsource-link-on-href-value.html extended to test this case.
+
+ * html/HTMLViewSourceDocument.cpp:
+ (WebCore::HTMLViewSourceDocument::processTagToken): Pass parsed URL to AddRange.
+ (WebCore::HTMLViewSourceDocument::addRange):Added argument for parsed URL, and used this instead of text, to create link.
+ * html/HTMLViewSourceDocument.h:
+ (HTMLViewSourceDocument): Add new link argument to addRange for parsed URL, defaulting to "".
+
2012-08-17 Yoshifumi Inoue <[email protected]>
[Forms] Rename SpinButtonElement::StepActionHandler to SpinButtonOwner
Modified: trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp (125877 => 125878)
--- trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp 2012-08-17 10:46:46 UTC (rev 125878)
@@ -158,7 +158,7 @@
index = addRange(source, index, iter->m_valueRange.m_start - token.startIndex(), "");
bool isLink = name == srcAttr || name == hrefAttr;
- index = addRange(source, index, iter->m_valueRange.m_end - token.startIndex(), "webkit-html-attribute-value", isLink, tagName == aTag);
+ index = addRange(source, index, iter->m_valueRange.m_end - token.startIndex(), "webkit-html-attribute-value", isLink, tagName == aTag, value);
++iter;
}
@@ -262,7 +262,7 @@
}
}
-int HTMLViewSourceDocument::addRange(const String& source, int start, int end, const String& className, bool isLink, bool isAnchor)
+int HTMLViewSourceDocument::addRange(const String& source, int start, int end, const String& className, bool isLink, bool isAnchor, const String& link)
{
ASSERT(start <= end);
if (start == end)
@@ -271,7 +271,7 @@
String text = source.substring(start, end - start);
if (!className.isEmpty()) {
if (isLink)
- m_current = addLink(text, isAnchor);
+ m_current = addLink(link, isAnchor);
else
m_current = addSpanWithClassName(className);
}
Modified: trunk/Source/WebCore/html/HTMLViewSourceDocument.h (125877 => 125878)
--- trunk/Source/WebCore/html/HTMLViewSourceDocument.h 2012-08-17 10:23:09 UTC (rev 125877)
+++ trunk/Source/WebCore/html/HTMLViewSourceDocument.h 2012-08-17 10:46:46 UTC (rev 125878)
@@ -58,7 +58,7 @@
void addLine(const AtomicString& className);
void finishLine();
void addText(const String& text, const AtomicString& className);
- int addRange(const String& source, int start, int end, const String& className, bool isLink = false, bool isAnchor = false);
+ int addRange(const String& source, int start, int end, const String& className, bool isLink = false, bool isAnchor = false, const String& link = String());
PassRefPtr<Element> addLink(const AtomicString& url, bool isAnchor);
PassRefPtr<Element> addBase(const AtomicString& href);