]> gitweb.factorcode.org Git - factor.git/commitdiff
html.parser: Strip trailing slashes / in html tags. Add unit test. Fixes #1233.
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Nov 2014 15:33:39 +0000 (09:33 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Nov 2014 15:33:39 +0000 (09:33 -0600)
extra/html/parser/parser-tests.factor
extra/html/parser/parser.factor

index 2876d03b163205ebf0dce8f95997ecd9cd5544a2..9607712bab3e9efa66e18af8b977ae9248d08df5 100644 (file)
@@ -96,3 +96,34 @@ V{
 ] [
     "<!--comment-->" parse-html
 ] unit-test
+
+! Issue #1233, trailing / in tags
+{
+    V{
+        T{ tag
+            { name "img" }
+            { attributes H{ { "src" "http://factorcode.org" } } }
+        }
+    }
+}
+[ "<img src=\"http://factorcode.org\">" parse-html ] unit-test
+
+{
+    V{
+        T{ tag
+            { name "img" }
+            { attributes H{ { "src" "http://factorcode.org" } } }
+        }
+    }
+}
+[ "<img src=\"http://factorcode.org\"/>" parse-html ] unit-test
+
+{
+    V{
+        T{ tag
+            { name "img" }
+            { attributes H{ { "src" "http://factorcode.org" } } }
+        }
+    }
+}
+[ "<img src=\"http://factorcode.org\"////////>" parse-html ] unit-test
index f31aaba698933e074544ff4884c1b157e3d2b0df..3b42e1b0921d94c66d5973d6634a29ae18d8ae08 100644 (file)
@@ -75,8 +75,10 @@ SYMBOL: tagstack
     [ advance advance read-comment ] [ read-dtd ] if ;
 
 : read-tag ( sequence-parser -- string )
-    [ [ current "><" member? ] take-until ]
-    [ dup current CHAR: < = [ advance ] unless drop ] bi ;
+    [
+        [ current "><" member? ] take-until
+        [ CHAR: / = ] trim-tail
+    ] [ dup current CHAR: < = [ advance ] unless drop ] bi ;
 
 : read-until-< ( sequence-parser -- string )
     [ current CHAR: < = ] take-until ;