Skip to content

Fix custom link label being double HTML-encoded on each save - #90

Open
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/custom-link-label-double-encode-89
Open

Fix custom link label being double HTML-encoded on each save#90
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/custom-link-label-double-encode-89

Conversation

@boo-code

Copy link
Copy Markdown
Questions Answers
Description? When editing a custom link (BO > ps_mainmenu config > Custom links), getAddLinkFieldsValues() decoded the link URL with Tools::htmlentitiesDecodeUTF8() before pre-filling the edit form, but left the label untouched. Ps_MenuTopLinks::getLinkLang() returns both the link and the label HTML-entity encoded (via Tools::safeOutput()), so the label was pre-filled already encoded and then re-encoded on save, stacking the entities on every edit/save cycle (ÀÀÀ → …) until the label became unreadable in the BO and the front office. The fix decodes the label exactly the same way the link is decoded.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #89.
How to test? Add a custom link with a label containing a special character (e.g. À propos), save, then edit and save it again a few times without changing anything. Before: the label in ps_linksmenutop_lang.label, in the link list and in the edit field gains an extra layer of HTML entities on each save. After: the label keeps its original value across saves. Verified against the database: editing a link whose stored label is À propos now pre-fills the form with À propos instead of À propos, so re-saving leaves it unchanged.
Sponsor company

Root cause spotted by @Daaaaad in the issue — getAddLinkFieldsValues() decoded $link['link'] but not $link['label'].

@ps-jarvis

Copy link
Copy Markdown

Hello @boo-code!

This is your first pull request on ps_mainmenu repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Jun 27, 2026
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.
@boo-code
boo-code force-pushed the fix/custom-link-label-double-encode-89 branch from 9d04716 to aca4667 Compare July 29, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Custom link label gets double-encoded with HTML entities on each save when it contains special characters

2 participants