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

Encoding issue when & html entity is followed by a ";" not preceded by a "&". #109

Closed
Laurianti opened this issue Oct 8, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Laurianti
Copy link

Laurianti commented Oct 8, 2021

Hello, I think this is a strange behaviour:

Code:

console.log('--- input ---------------------------------------------');
console.log(input);
var output = create(input);
console.log('--- output --------------------------------------------');
console.log(output.toString({prettyPrint: true}));

Output:

--- input ---------------------------------------------
<?xml version="1.0"?>
<testsuites>
  <testsuite>
    <testcase name="&amp;"/>
    <!-- OK -->
    <testcase name="&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&amp;"/>
    <!-- OK -->
    <testcase name="&quot;&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&fake;"/>
    <!-- OK -->
    <testcase name="&amp;&;"/>
    <!-- OK -->
    <testcase name="&quot;;"/>
    <!-- OK -->
    <testcase name="&quot;!;"/>
    <!-- OK -->
    <testcase name="&amp;;"/>
    <!-- BROKEN -->
    <testcase name="&amp;!;"/>
    <!-- BROKEN -->
    <testcase name="&amp;abc;def"/>
    <!-- BROKEN -->
    <testcase name="Hello &amp; world today; or tomorrow"/>
    <!-- BROKEN -->
  </testsuite>
</testsuites>

--- output --------------------------------------------
<?xml version="1.0"?>
<testsuites>
  <testsuite>
    <testcase name="&amp;"/>
    <!-- OK -->
    <testcase name="&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&amp;"/>
    <!-- OK -->
    <testcase name="&quot;&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&quot;"/>
    <!-- OK -->
    <testcase name="&amp;&fake;"/>
    <!-- OK -->
    <testcase name="&amp;&;"/>
    <!-- OK -->
    <testcase name="&quot;;"/>
    <!-- OK -->
    <testcase name="&quot;!;"/>
    <!-- OK -->
    <testcase name="&;"/>
    <!-- BROKEN -->
    <testcase name="&!;"/>
    <!-- BROKEN -->
    <testcase name="&abc;def"/>
    <!-- BROKEN -->
    <testcase name="Hello & world today; or tomorrow"/>
    <!-- BROKEN -->
  </testsuite>
</testsuites>

This happen when & html entity is followed by a ";" not preceded by a "&".

Should be fixed?

@Laurianti Laurianti added the bug Something isn't working label Oct 8, 2021
@Laurianti Laurianti changed the title Strange behaviour caused by double semicolon with html entity Encoding issue when the html entity is followed by a ";" not preceded by a "&". Oct 9, 2021
@Laurianti Laurianti changed the title Encoding issue when the html entity is followed by a ";" not preceded by a "&". Encoding issue when &amp; html entity is followed by a ";" not preceded by a "&". Oct 9, 2021
@HenkBoxma
Copy link

HenkBoxma commented Nov 12, 2021

@oozcitak : Hi Ozgur, This issues is pretty blocking for us. Do you know if and when we could expect a fix? Kind regards, Henk

coffeemakr added a commit to coffeemakr/xmlbuilder2 that referenced this issue Mar 28, 2022
The current regex for replacing ampersands has a flawed check to see if the ampersand is used HTML-encoded character. The regex isn't working because it ignores whitespace between the `&` and the `;` character. Also I don't think it's the responsibility of the writer to interpret if a value has been encoded already. This should fix oozcitak#110 and oozcitak#109
@coffeemakr coffeemakr mentioned this issue Mar 28, 2022
4 tasks
@jgrubb16
Copy link
Contributor

jgrubb16 commented Nov 8, 2022

Is there any update on merging this change anytime soon? I'm also experiencing this issue and I see this has been open since last year.

@jgrubb16 jgrubb16 mentioned this issue Nov 11, 2022
4 tasks
@jgrubb16
Copy link
Contributor

@oozcitak Just made #154 to help bring this across the finish line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants