Wicket
  1. Wicket
  2. WICKET-5398

XmlPullParser fails to properly parse from String with encoding declaration

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 6.11.0, 7.0.0-M1
    • Fix Version/s: 6.12.0, 7.0.0-M1
    • Component/s: wicket
    • Labels:
      None

      Description

      When parsing from a string, XmlPullParser fails if the encoding from the XML declaration is different than the system's file encoding.

      Examples:
      -Dfile.encoding=ISO-8859-1
      parser.parse("<?xml encoding='UTF-8' ?><span id='umlaut-äöü'></span>");

      -Dfile.encoding=UTF-8
      parser.parse("<?xml encoding='ISO-8859-1' ?><span id='umlaut-äöü'></span>");

      Both fail because the string is read with the system's file encoding while the parser expects the stream to be encoded in the declarated encoding.

        Activity

        Hide
        Martin Grigorov added a comment -

        I believe this conversation is related - http://markmail.org/thread/4emvqzvcui6sojds

        Show
        Martin Grigorov added a comment - I believe this conversation is related - http://markmail.org/thread/4emvqzvcui6sojds
        Hide
        Sven Meier added a comment -

        Thanks Martin, I wasn't aware of this discussion.

        Juergen wrote:
        >To support unit testing XPP provide a parse(String) method which encapsulates the string into a inputstream,
        >in order not to circumvent XmlReader for testing.

        I'm revisit my change and check why it should be 'bad to circumvent XmlReader' in testing.

        Show
        Sven Meier added a comment - Thanks Martin, I wasn't aware of this discussion. Juergen wrote: >To support unit testing XPP provide a parse(String) method which encapsulates the string into a inputstream, >in order not to circumvent XmlReader for testing. I'm revisit my change and check why it should be 'bad to circumvent XmlReader' in testing.
        Hide
        Sven Meier added a comment -

        IMHO it's better to circumvent any encoding problem by using a StringReader directly on the parsed String.

        XmlPullParserTest makes sure detection of XML encoding still works.

        Show
        Sven Meier added a comment - IMHO it's better to circumvent any encoding problem by using a StringReader directly on the parsed String. XmlPullParserTest makes sure detection of XML encoding still works.

          People

          • Assignee:
            Sven Meier
            Reporter:
            Sven Meier
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development