From 731a8eef6a62c4dbb716f771c90af34e7f2feecf Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Sat, 20 Mar 2021 15:00:24 +0100 Subject: [PATCH 1/4] Escapes the quotes and enable double encode --- index.php | 2 +- lib-htmgem.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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); } From 710bd1bf072222a4dc499d2b4b5ca5233653dea6 Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Sat, 20 Mar 2021 22:41:04 +0000 Subject: [PATCH 2/4] Corrects blockquote size on mobile --- css/htmgem.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/htmgem.css b/css/htmgem.css index cb189a9..dbda462 100644 --- a/css/htmgem.css +++ b/css/htmgem.css @@ -114,7 +114,7 @@ pre { h3 { font-size: 3rem; } - p, pre, ul { + p, pre, ul, blockquote { font-size: 2.6rem; } } From c1299a2bdb5a2a35ed896bf9619645c497c1c60f Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Sun, 21 Mar 2021 00:14:55 +0100 Subject: [PATCH 3/4] FIX: adds line feed inside a blockquote Example: > line_1 > line_2 Before : line_1 line_2 After : Line_1 Line_2 --- lib-htmgem.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib-htmgem.php b/lib-htmgem.php index d888ddd..558dbb1 100644 --- a/lib-htmgem.php +++ b/lib-htmgem.php @@ -271,9 +271,11 @@ class GemtextTranslate_html { echo "
\n$text\n
\n"; break; case ">": - $text = implode("\n", $node["texts"]); - self::htmlPrepare($text); - if ($textDecoration) self::addTextDecoration($text); + foreach ($node["texts"] as &$text) { + self::htmlPrepare($text); + if ($textDecoration) self::addTextDecoration($text); + } + $text = implode("
\n", $node["texts"]); echo "
\n$text\n
\n"; break; case "=>": From 4e42fed6b40f0c85fdec02cf4c3c03e623b74615 Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Sun, 21 Mar 2021 00:19:58 +0100 Subject: [PATCH 4/4] Adds null space between two slashes --- index.gmi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.gmi b/index.gmi index 7367289..f140353 100644 --- a/index.gmi +++ b/index.gmi @@ -88,7 +88,7 @@ Lorsque l’option css est activé dans la configuration (voir //rewrite// plus ## Réécriture d’URL pour préciser le style à utiliser Modifier la configuration du serveur web fonctionne mais est assez lourd. On peut tester un style en particulier de la façon suivante : -> https://site.tld/htmgem/index.php?url=/url/page.gmi&style=<…> +> https:/​/site.tld/htmgem/index.php?url=/url/page.gmi&style=<…> Il est aussi possible de faire une réécriture d’URL qui intègre le style : > rewrite ^(.+\.gmi)$ /htmgem/?url=$1;