Fixed img src URLS with multiple spaces
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2013 19:09:05 +0000 (19:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2013 19:09:05 +0000 (19:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121592

Patch by Yoav Weiss <yoav@yoav.ws> on 2013-09-20
Reviewed by Darin Adler.

Source/WebCore:

Test: fast/loader/image-src-multiple-space.html

I've removed the simplifyWhiteSpace step from HTMLImageElement's src attribute during the srcset selection algorithm.
That step prevented URLs with multiple spaces from being loaded as images, minimizing the multiple spaces into a single one.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::bestFitSourceForImageAttributes):

LayoutTests:

This test verifies that URLs with multiple spaces can be loaded as an image resource.

* fast/loader/image-src-multiple-space-expected.txt: Added.
* fast/loader/image-src-multiple-space.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156186 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/loader/image-src-multiple-space-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/image-src-multiple-space.html [new file with mode: 0644]
LayoutTests/fast/loader/resources/image space.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLParserIdioms.cpp

index c55f03cc8a9f1bc1010e34decfb41b3ff1198f6f..799a6c3c125ac69694f86207b3b41b0510ae375c 100644 (file)
@@ -1,3 +1,15 @@
+2013-09-20  Yoav Weiss  <yoav@yoav.ws>
+
+        Fixed img src URLS with multiple spaces
+        https://bugs.webkit.org/show_bug.cgi?id=121592
+
+        Reviewed by Darin Adler.
+
+        This test verifies that URLs with multiple spaces can be loaded as an image resource.
+
+        * fast/loader/image-src-multiple-space-expected.txt: Added.
+        * fast/loader/image-src-multiple-space.html: Added.
+
 2013-09-20  Arunprasad Rajkumar  <ararunprasad@gmail.com>
 
         Hiding a focused element should unfocus it and fire a blur event
diff --git a/LayoutTests/fast/loader/image-src-multiple-space-expected.txt b/LayoutTests/fast/loader/image-src-multiple-space-expected.txt
new file mode 100644 (file)
index 0000000..b09af52
--- /dev/null
@@ -0,0 +1,3 @@
+PASS document.getElementById("foo").clientWidth==25 is true
+This test passes if the image below is displayed.
+
diff --git a/LayoutTests/fast/loader/image-src-multiple-space.html b/LayoutTests/fast/loader/image-src-multiple-space.html
new file mode 100644 (file)
index 0000000..a2b2daa
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+    addEventListener("load", function() {
+        shouldBeTrue('document.getElementById("foo").clientWidth==25');
+    }, false);
+</script>
+</head>
+
+<body id="body">
+    <div>This test passes if the image below is displayed.</div>
+    <img id="foo" src="resources/image  space.png">
+</body>
+</html>
diff --git a/LayoutTests/fast/loader/resources/image space.png b/LayoutTests/fast/loader/resources/image space.png
new file mode 100644 (file)
index 0000000..6e555e3
Binary files /dev/null and b/LayoutTests/fast/loader/resources/image space.png differ
index 7f97af2bede8d794772ee6bd660d621facb4bf3b..4bf772aaa1c0082a671e2544ce4d3a575ff53cb9 100644 (file)
@@ -1,3 +1,18 @@
+2013-09-20  Yoav Weiss  <yoav@yoav.ws>
+
+        Fixed img src URLS with multiple spaces
+        https://bugs.webkit.org/show_bug.cgi?id=121592
+
+        Reviewed by Darin Adler.
+
+        Test: fast/loader/image-src-multiple-space.html
+
+        I've removed the simplifyWhiteSpace step from HTMLImageElement's src attribute during the srcset selection algorithm.
+        That step prevented URLs with multiple spaces from being loaded as images, minimizing the multiple spaces into a single one.
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::bestFitSourceForImageAttributes):
+
 2013-09-20  Arunprasad Rajkumar  <ararunprasad@gmail.com>
 
         Hiding a focused element should unfocus it and fire a blur event
index 9bde6239e87d742db83959c1907e7a8241637594..a7cb72e2fb97d6b562160b41c1dd2e898476dd5d 100644 (file)
@@ -405,10 +405,9 @@ String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr
 
     parseImagesWithScaleFromSrcsetAttribute(srcsetAttribute, imageCandidates);
 
-    const String src =  srcAttribute.simplifyWhiteSpace(isHTMLSpace);
-    if (!src.isEmpty()) {
+    if (!srcAttribute.isEmpty()) {
         ImageWithScale image;
-        image.imageURL = src;
+        image.imageURL = srcAttribute;
         image.scaleFactor = 1.0;
 
         imageCandidates.append(image);