diff --git a/index.php b/index.php index a551626..b286ba5 100644 --- a/index.php +++ b/index.php @@ -80,7 +80,7 @@ if ("source" == $style) { # Gets the page title: the first occurrence with # at the line start mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches); $page_title = @$matches[1]; - $fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false); + $fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_QUOTES, "UTF-8", true); echo << diff --git a/lib-htmgem.php b/lib-htmgem.php index a5635fa..d888ddd 100644 --- a/lib-htmgem.php +++ b/lib-htmgem.php @@ -232,7 +232,7 @@ class GemtextTranslate_html { if (empty($text)) { $text = " "; } else { - $text = htmlspecialchars($text, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false); + $text = htmlspecialchars($text, ENT_HTML5|ENT_QUOTES, "UTF-8", true); $text = mb_ereg_replace("\ ([?!:;»€$])", self::NARROW_NO_BREAK_SPACE."\\1", $text); $text = mb_ereg_replace("([«])\ ", "\\1".self::NARROW_NO_BREAK_SPACE, $text); # Espace fine insécable @@ -283,6 +283,9 @@ class GemtextTranslate_html { $linkText = $link; self::htmlPrepare($linkText); } else { + // Don't double encode, just escapes quotes, "<" and ">". + // So "I'm>" becomes "I'>". The & remains untouched. + $link = htmlspecialchars($link, ENT_HTML5|ENT_QUOTES, "UTF-8", false); self::htmlPrepare($linkText); if ($textDecoration) self::addTextDecoration($linkText); }