]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/help/html/html.factor
help.html: check filename for printable characters
[factor.git] / basis / help / html / html.factor
index 806acf7d38ef048553036713457a30ecf1cb4757..7b9ef4f6f9c74b59d2f3b7596d38990ea05d717c 100644 (file)
@@ -13,6 +13,11 @@ FROM: io.encodings.ascii => ascii ;
 FROM: ascii => ascii? ;
 IN: help.html
 
+ERROR: not-printable ch ;
+
+: check-printable ( ch -- ch )
+    dup printable? [ not-printable ] unless ;
+
 : escape-char ( ch -- )
     dup ascii? [
         [
@@ -31,7 +36,7 @@ IN: help.html
                 { CHAR: # "__hash__" }
                 { CHAR: % "__percent__" }
             } at
-        ] [ % ] [ , ] ?if
+        ] [ % ] [ check-printable , ] ?if
     ] [ number>string "__" "__" surround % ] if ;
 
 : escape-filename ( string -- filename )