[fpc-devel] XML canonical
sergei_gorelkin at mail.ru
Fri Aug 28 15:59:33 CEST 2009
Dariusz Mazur wrote:
> this is my first approach to implement canonical transform
> from <ds:CanonicalizationMethod
> its used in XADES sign.
> can somebody review it, if its interesting
First of all, it ignores the fact that DOM is based on WideStrings
(UTF-16 encoding). Plain assignments of DOM properties to string (or
UTF8String) will cause conversion to system locale encoding. It will
happen to work if system locale is actually utf-8, but won't work
correctly e.g. in Windows.
Next, a number of crude errors can be seen just by reading the source.
For example, a processing instruction is delimited by '<?' and '?>', not
by '<!' and '>'. It lacks escaping '<' by '<' and '&' by '&' in
both text and attributes. Attribute value normalization must not only
replace #13, #9 and #10 by space, but also trim leading and trailing
whitespace and replace all consequtive whitespaces by single space (and
it is already done by DOM for non-CDATA attributes).
I'd suggest you to find a test suite (some examples are contained
directly in the text of w3.org specification, others may be ripped from
opensource projects that support canonicalization, like libxml2) and
verify your unit against it.
More information about the fpc-devel