]> gitweb.factorcode.org Git - factor.git/commitdiff
help.html: check filename for printable characters
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 31 Aug 2023 21:04:06 +0000 (14:04 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 31 Aug 2023 21:04:06 +0000 (14:04 -0700)
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 )