From aca4667ef1c7110163f1fc7c4342347df15d62a6 Mon Sep 17 00:00:00 2001 From: Audrius Date: Sat, 27 Jun 2026 04:41:26 +0200 Subject: [PATCH] Fix custom link label being double HTML-encoded on each save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When editing a custom link, getAddLinkFieldsValues() decoded the link URL with Tools::htmlentitiesDecodeUTF8() before pre-filling the edit form, but left the label untouched. Ps_MenuTopLinks::getLinkLang() returns both values HTML-entity encoded (Tools::safeOutput), so the label was pre-filled already encoded and re-encoded on save, stacking the entities on every edit cycle (e.g. "À" -> "À" -> "À" -> ...) until the label became unreadable. Decode the label the same way the link is decoded, so the edit form shows the real value and saving it keeps it unchanged. --- ps_mainmenu.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ps_mainmenu.php b/ps_mainmenu.php index c3ddd9f..96fe7ef 100644 --- a/ps_mainmenu.php +++ b/ps_mainmenu.php @@ -1359,6 +1359,14 @@ public function getAddLinkFieldsValues() $link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label); } + // Decode the label as well, the same way the link is decoded above. getLinkLang() + // returns it HTML-entity encoded (Tools::safeOutput), so without this the edit form + // pre-fills with the encoded value and re-encodes it on every save, stacking the + // entities (e.g. "À" -> "À" -> "À" -> ...). + foreach ($link['label'] as $key => $label) { + $link['label'][$key] = Tools::htmlentitiesDecodeUTF8($label); + } + $links_label_edit = $link['link']; $labels_edit = $link['label']; $new_window_edit = $link['new_window'];