Code Monkey home page Code Monkey logo

Comments (7)

SmartLayer avatar SmartLayer commented on June 14, 2024 2

Looks like the problem is in xmldom module
xmldom/xmldom#22

You are right on this, but xmldom closed that bug without resolving it. I refiled it as xmldom/xmldom#203

from xmldsigjs.

micwallace avatar micwallace commented on June 14, 2024 1

This fix is now in pre-release @xmldom/xmldom@^0.9.0-beta.6

xmldom/xmldom#203

from xmldsigjs.

SmartLayer avatar SmartLayer commented on June 14, 2024

This is more mysterious than I thought! If I change the test XML into this:

<x:html xmlns:x="http://www.w3.org/1999/xhtml" xml:lang="en"><x:body><x:script type="text/javascript">
let message = " &amp; ETH";</x:script></x:body></x:html>

That is, take the XML that can reproduce this bug, which has xmlns, replace it with x:xmlns and prefix every element with x:, then the canonicalization result is correct!

<x:html xmlns:x="http://www.w3.org/1999/xhtml" xml:lang="en"><x:body><x:script type="text/javascript">
let message = " &amp; ETH";</x:script></x:body></x:html>

I feel this is the kind of bug that takes a few miutes to make or correct yet a few hours to find out! Spent quite a few hours to strip down complicated XML files to produce a demonstration.

from xmldsigjs.

SmartLayer avatar SmartLayer commented on June 14, 2024

Is there any way we can address this issue? This issue really look like a problem related to hardcoding certain rules when the default xmlns points to XHTML. Observe that if you change

<html xmlns="http://www.w3.org/1999/xhtml"

to

<html xmlns="http://www.w3.org/1999/xhtm"

(deleted one letter l)

Then the canonicalised output becomes correct.

It seems that the following rules are at work in either this project or some of the dependent libraries:

  1. Normally, & in the text node denotes the beginning of an entity;
  2. But, if the current node containing the text node is in XHTML namespace, rule that & denotes the literal & (against XHTML);
  3. But, in rule 2, if the current node containing the text node is in XHTML namespace through the use of a prefix (not through the default xmlns), then rule 2 doesn't apply and the document is treated as a normal XML file (where & denotes the begining of an entity.

from xmldsigjs.

rmhrisk avatar rmhrisk commented on June 14, 2024

We can look at it but @microshine is tied up with other work at the moment. We will get back to your issue when that’s done.

from xmldsigjs.

microshine avatar microshine commented on June 14, 2024

Looks like the problem is in xmldom module
xmldom/xmldom#22

from xmldsigjs.

SmartLayer avatar SmartLayer commented on June 14, 2024

I'm closing this for now since I expect this issue to disappear if xmldom/xmldom#203 is solved.

from xmldsigjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.