jkesselm opened a new pull request, #168: URL: https://github.com/apache/xalan-java/pull/168
As [Cédric Damioli](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=cdamioli) has pointed out, the logic in Encodings.java relied upon `Hashtable` behavior that changed between Java 1.8 and Java 17. In different levels of java the mapping from MIME encoding name to Java encoding names could yield different results. This seems to be related to how Hashtable reacted when given a new entry with the same key as an existing one. In particular, `encodings.properties` contains: ```ISO8859-1 ISO-8859-1 0x00FF ISO8859_1 ISO-8859-1 0x00FF 8859-1 ISO-8859-1 0x00FF 8859_1 ISO-8859-1 0x00FF``` The latter two "shorthand" names, despite being in the "Java name" column, are not actually synonyms for this encoding in Java, and in more recent JREs the MIME name could be mapped to one of them as easily as to the first two. The result would be that output would not be encoded properly. The simplest fix we've found is to make that resolution explicit, by replacing`put()` with `putIfAbsent()` when building the mapping tables, so that the first mapping of the MIME encoding in the file asserts the correct Java encoding equivalent, much as the first encoding in a group of comma-separated MIME encodings is taken as the preferred mapping from the associated Java encoding. This fix retains the ability to accept all the existing encoding names, and to work with possible user-modified versions of the `encodings.properties` file, while giving us behavior that is correct/predictable despite the changes in Java Hashtable. (Theoretically, we could also add the comma-separated-list behavior to the Java Encoding Name column of `encodings.properties`, reducing those four lines to one and being more directly equivalent to the handling of MIME encoding names. We might even be able to use a single Hashtable for all the keys rather than needing separate ones for the Java and MIME names. But that would go beyond least-change bug fixing; if anyone thinks it's important please feel free to add it to the Jira backlog as a low-priority feature request.) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org For additional commands, e-mail: dev-h...@xalan.apache.org