SWI-Prolog / packages-sgml

The SWI-Prolog SGML/XML/HTML parser
4 stars 10 forks source link

Keep prefix in attributes #32

Closed thetrime closed 4 years ago

thetrime commented 4 years ago

This changes the behaviour of the parser so that if keep_prefix(true) is specified then attributes also have a ns/2, if appropriate.

It also changes c14n2.pl to deal with these ns/2 objects, including a fix for the case where 2 different prefixes refer to the same URI. For example:

<Document xmlns:ns1="some_namespace" ns1:foo="bar">
  <SubDocument  xmlns:ns2="some_namespace" ns2:qux="baz"/>
</Document>

The critical point being that xmlns:ns1 and xmlns:ns2 are both 'some_namespace'. Once we have loaded the structure, we cannot tell what 'some_namespace':qux is: Is it ns1 or ns2? (Of course, the sensible answer of: "Who cares? They're both the same URI!" only applies if you're not trying to make a hash of the result for XML signature verification)

JanWielemaker commented 4 years ago

Thanks. Applied after edit of commit message. Hope this is the end of XML signatures :)

You might want to add some tests for these signatures as this seems very sensitive to things that may look like innocent changes.