Stop text from being encoded again on every save
Umut: "Beim Startseitenbild wird der Text & umgewandelt, aber in der Ansicht nach dem Speichern wird & daraus." RichText::sanitise() treated text without a single tag as plain text and only escaped it. What the editor sends is HTML, tag or no tag - so "Freudenstadt & Umgebung" gained one level of encoding on every save (&amp;, &amp;amp; ...) until the entity stood on the page for everyone to read. The draft of the kant-it.de home page had already reached three levels. The same branch carried a second fault of the same kind: nl2br() left the newline behind the <br>, and the next pass turned it into a second <br> via breakLines() - one paragraph became two. The branch now decodes first and replaces the line break instead of adding to it, so it ends up with the same representation as the DOM branch and both are stable under repeated saves. scripts/repair-doubled-entities.php cleans up what is already stored: the published and draft revision of every page and the areas, with a dry run, each change checked against the validator. Older revisions stay as history. DEEG: favicon is now its own square mark - the roof gable from the logo, white on the logo blue, rendered from logo-deeg.png - instead of the centre crop of the wide logo, which showed the "EE" of the wordmark. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d885b3ddb5
commit
4539f357c1
6 files changed
+297
-1
No files matched your search
@@ -50,7 +50,19 @@ final class RichText
|
||||
}
|
||||
if (!str_contains($html, '<')) {
|
||||
// Plain text: escape it and keep line breaks, so typing without formatting still works.
|
||||
return nl2br(htmlspecialchars($html, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), false);
|
||||
//
|
||||
// Erst dekodieren: Was aus dem Editor kommt, ist HTML - auch ohne ein einziges Tag.
|
||||
// „Freudenstadt & Umgebung“ meint ein kaufmaennisches Und. Ohne diesen Schritt
|
||||
// wuerde daraus bei jedem Speichern eine Entity mehr (&amp;, &amp;amp; ...),
|
||||
// bis sie sichtbar auf der Seite steht. Der Zweig mit Tags macht es ueber den DOM
|
||||
// laengst richtig; dieser hier zog nach.
|
||||
$text = html_entity_decode($html, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Der Umbruch wird ersetzt, nicht ergaenzt: nl2br() liess den Zeilenumbruch
|
||||
// hinter dem <br> stehen, und beim naechsten Speichern machte breakLines()
|
||||
// daraus ein zweites <br> - aus einem Absatz wurden zwei. So enden beide Zweige
|
||||
// bei derselben Darstellung.
|
||||
return str_replace(["\r\n", "\r", "\n"], '<br>', htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
|
||||
}
|
||||
|
||||
$document = new \DOMDocument();
|
||||
|
||||
Reference in new issue
Block a user