Skip to content

Fix warnings on HTML elements in placeholders - #4529

Merged
flodolo merged 3 commits into
mozilla:mainfrom
flodolo:issue4524_part2
Sep 15, 2026
Merged

flodolo merged 3 commits into
mozilla:mainfrom
flodolo:issue4524_part2

Conversation

@flodolo

@flodolo flodolo commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

In the last commit of #4525, I oversimplified the code on a wrong assumption after testing that everything was working

"The parser can't produce <a href="{$arg1 :string @source=|%1$s|}">. <a href="%1$s">policy</a> is parsed as {#a href=|%1$s|}policy{/a}"

That's only true for raw, unescaped XML elements, not for escaped HTML (&lt;a href="%1$s"&gt;…&lt;/a&gt;), which is the case for markup in Android strings.xml files.

Updating tests and adding in the docstring what's the textual representation of the string, since it only shows up as MF2 in the code.

Fixes #4524.

Tested locally and the string is submitted without errors or warnings.

In the last commit in the mozilla#4525, I oversimplified the code on a wrong assumption

> ▎ "The parser can't produce <a href="{$arg1 :string @source=|%1$s|}"> — <a href="%1$s">policy</a> is parsed as {#a href=|%1$s|}policy{/a}"

That's only true for raw, unescaped XML elements, not for escaped HTML (`&lt;a href="%1$s"&gt;…&lt;/a&gt;`), which is the case for markup in Android strings.xml.

Updating tests and adding in the docstring what's the textual representation of the string, since it only shows up as MF2 in the code.

Fixes mozilla#4524
@flodolo
flodolo requested a review from mathjazz September 15, 2026 18:06

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. See one comment inline.

Just started deployment to DEV.

Comment thread pontoon/checks/libraries/custom.py Outdated
Comment on lines +320 to +322
rest = pat_src[pm.start() :]
for ph in src_ph_strings:
if pat_src.startswith(ph, pm.start()):
if rest.startswith(ph):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this change? The logic is the same, it's more code and less efficient.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a mistake. I reverted the commit, and forgot to keep the optimization.

@flodolo
flodolo merged commit edbb875 into mozilla:main Sep 15, 2026
7 checks passed
@flodolo
flodolo deleted the issue4524_part2 branch September 15, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot save translation that has a placeholder inside an html tag

2 participants