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 c55f03c..799a6c3 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 7f97af2..4bf772a 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 9bde623..a7cb72e 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);