]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
preprocess: Escape most ASCII punctuation in error messages
authorSimon McVittie <smcv@debian.org>
Wed, 28 Feb 2018 09:40:45 +0000 (09:40 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 28 Feb 2018 09:55:53 +0000 (09:55 +0000)
This is a minimal version of what we should in principle do here,
which is to escape the error message in whatever way is correct for
embedding plain text in the surrounding wiki markup language.
This implementation approximates that by assuming that HTML entities,
alphanumerics and common punctuation characters are passed through the
markup language unaltered, but punctuation characters might be
misinterpreted.

Signed-off-by: Simon McVittie <smcv@debian.org>
IkiWiki.pm

index 0d87242ebd53c07f62b0446a0b102550afee83de..7a38c8f89a44fd42d7e61a2871dd2014e4ac3b09 100644 (file)
@@ -1668,6 +1668,10 @@ sub preprocess ($$$;$$) {
                                        chomp $error;
                                        eval q{use HTML::Entities};
                                        $error = encode_entities($error);
+                                       # Also encode most ASCII punctuation
+                                       # as entities so that error messages
+                                       # are not interpreted as Markdown etc.
+                                       $error = encode_entities($error, '[](){}!#$%*?@^`|~'."\\");
                                        $ret="[[!$command <span class=\"error\">".
                                                gettext("Error").": $error"."</span>]]";
                                }