Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The entity name must immediately follow the '&' in the entity reference #66

Open
justodepp opened this issue May 18, 2023 · 8 comments
Open
Assignees
Labels

Comments

@justodepp
Copy link

  • Plug-in Version 3.4.0

As for the title the error message it's the same

"The entity name must immediately follow the '&' in the entity reference"

tested also on version 3.3.1 and this version doesn't have this issue.

Thanks

@adriangl
Copy link
Collaborator

Hi @justodepp!
Do you have any sample string that I can use to reproduce the error?

Thanks!

@justodepp
Copy link
Author

justodepp commented May 18, 2023 via email

@carlosrivin
Copy link

Had the same issue just now. Because of the same string :)

@adriangl
Copy link
Collaborator

adriangl commented Aug 28, 2023

Hey @justodepp @carlosrivin! Sorry for replaying so late.
I've been testing version 3.4.1 of the plug-in with these strings:

    "test_issue_66_1" -> "T&C"
    "test_issue_66_2" -> "T & C"
    "test_issue_66_3" -> "T & C"

and got the following results:

    <string name="test_issue_66_1">"T&amp;C"</string>
    <string name="test_issue_66_2">"T &amp; C"</string>
    <string name="test_issue_66_3">"T &amp;amp; C"</string>

These should be the proper escape sequences so I believe the plugin is working as expected. Does the error happen when using the plugin or when compiling your apps?

@justodepp
Copy link
Author

justodepp commented Aug 29, 2023 via email

@bogdanzurac
Copy link
Contributor

bogdanzurac commented Aug 30, 2023

We've had the same issue in one of our own projects.
PoEditor CMS contains the following string:
image

When using this config (which doesn't specify the unescapeHtmlTags field), we get the error:

poEditor {
    apiToken.set("xxx")
    projectId.set(123)
    order.set("terms")
    tags.set(listOf("android", "app"))
    unquoted.set(true)
}

However, when turning unescapeHtmlTags to false, it works without any issues:

poEditor {
    apiToken.set("xxx")
    projectId.set(123)
    order.set("terms")
    tags.set(listOf("android", "app"))
    unquoted.set(true)
    unescapeHtmlTags.set(false)
}

<string name="puf_details_solutions">Common problems &amp; solutions</string>

This happens because the default value of unescapeHtmlTags is true. It seems rather confusing that we need to toggle the default value of the unescapeHtmlTags field in order to affect ampersand parsing, as it should work regardless of this config value.

@nokite
Copy link
Contributor

nokite commented Mar 15, 2024

This started happening in our project when we updated:
from AGP 4.2.2 + gradle 6.9 + java 8
to AGP 8.3.0 + gradle 8.4 + java 17 (build), java 11 (source)

It happens both with plugin version 3.4.2 and 4.2.0.

Caused by: org.xml.sax.SAXParseException; lineNumber: 1601; columnNumber: 59; The entity name must immediately follow the '&' in the entity reference.
        at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
        at com.hyperdevs.poeditor.gradle.ktx.DocumentExtensionsKt.toStringsXmlDocument(DocumentExtensions.kt:41)
        at com.hyperdevs.poeditor.gradle.xml.XmlPostProcessor.splitTranslationXml(XmlPostProcessor.kt:113)
        at com.hyperdevs.poeditor.gradle.xml.XmlPostProcessor.postProcessTranslationXml(XmlPostProcessor.kt:55)
        at com.hyperdevs.poeditor.gradle.PoEditorStringsImporter.importPoEditorStrings(PoEditorStringsImporter.kt:146)
        at com.hyperdevs.poeditor.gradle.tasks.ImportPoEditorStringsTask.importPoEditorStrings(ImportPoEditorStringsTask.kt:184)

Nice that unescapeHtmlTags = false fixes the issue. It introduces some other changes though. Some seem fine, some can be problematic.

This seems fine - it changes emoji codes/formats, but they still work.
For instance, it changes this string &#x1f929; into &#129321;. Both resolve to the same emoji - 🤩. The first one is the emoji Hex code point (as it was originally, before upgrading AGP, gradle and Java). The second one is the Decimal code point of the same emoji.

This does not seem fine though - it encodes tags, so they don't work anymore. For instance, it breaks tags like <b>. You might be using this tag to make text bold in the Android UI (works even in Toast messages). For instance:
John is \"<b>awesome</b>\", really! will output "John is "awesome", really!"

But it will be broken when using unescapeHtmlTags = false. The translation is saved this way:
John is \"&lt;b&gt;awesome&lt;/b&gt;\", really!
Which appears like this in the UI (it doesn't pick up the tags):
John is \"<b>awesome</b>\", really!

@LightWeek
Copy link

LightWeek commented Jun 6, 2024

Having the same exact issue.
Plugin version: 4.2.0
The term in POEditor is:
image

Enable Alarm & Reminders - issue reproduces, gradle task fails
Enable Alarm &amp; Reminders - task succeeds, the result is "Enable Alarm & Reminders" (& breaks Android strings in that case)
Enable Alarm &amp;amp; Reminders- task succeeds, produces correct Android string: "Enable Alarm &amp; Reminders"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants