he icon indicating copy to clipboard operation
he copied to clipboard

Incorrect error message for unknown named character references

Open youming-lin opened this issue 8 years ago • 3 comments

A minor issue:

he.decode('&abc;', {strict: true}) throws error with this message: Parse error: named character reference was not terminated by a semicolon, when in fact neither a nor ab are valid legacy named character references and &abc; is terminated by ;. I think an error message to the effect of Parse error: named character reference is not spec-defined would be better in this case.

This and #50 notwithstanding, he has been a great companion to the HTML5 spec as I learn about and write a spec-compliant HTML entity decoder for Swift :)

youming-lin avatar Oct 13 '16 15:10 youming-lin

Another excellent report. Thank you, @youming-lin!

Will your decoder be open-source?

mathiasbynens avatar Oct 13 '16 17:10 mathiasbynens

@mathiasbynens Yup, it is Apache 2.0 licensed: https://github.com/IBM-Swift/swift-html-entities

Version 1 supports HTML4 named character references; I'm currently working on version 2 which will support HTML5 named character references and improve parsing to detect parse errors as defined in the spec.

youming-lin avatar Oct 13 '16 18:10 youming-lin