Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2883

Bad XML parse encoding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 4.5.5.Final
    • jaxrs
    • Hide

      In my case, I call this URI http://www.aemet.es/xml/municipios/localidad_28007.xml with Invocation.Builder and read response with javax.ws.rs.core.Response.readEntity(GenericType<T>).

      This URI doesn't indicate charset in Content-Type header

      Show
      In my case, I call this URI  http://www.aemet.es/xml/municipios/localidad_28007.xml with Invocation.Builder and read response with javax.ws.rs.core.Response.readEntity( GenericType < T > ). This URI doesn't indicate charset in Content-Type header
    • Undefined

    Description

      Reading an ISO-8859-15 encoded XML I get an UTF8 encoder that fails.

      Debugging, I found AbstractJAXBProvider.processWithSecureProcessing:281 sets UTF8 by default if charset is null:


      https://github.com/resteasy/Resteasy/blob/main/providers/jaxb/src/main/java/org/jboss/resteasy/plugins/providers/jaxb/AbstractJAXBProvider.java

      By doing so, in XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl of apache Xerces

      this.fEntityScanner.getCurrentEntity().isEncodingExternallySpecified() evaluates to true, and setEncoding is not called, letting UTF-8 be the wrong encoding and failing.

       

      If I just reset encoding to null it works perfectly.

      Attachments

        Activity

          People

            pberan@redhat.com Petr Beran
            aladera2 Alejandro Ladera Chamorro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: