Invalid encoding of Rhino JavaScript files
Closed this issue · 1 comments
karelmaxa commented
Rhino is using bad JavaScript file encoding (ISO-8859-1
instead of UTF-8
) when running on Java 11 (openjdk 11.0.15+
) or newer. These Java versions contain new content type text/javascript
for JavaScript files (files with .js
extension). This content type was added into JDK in JDK-8273655.
Current implementation of Rhino is using ISO-8859-1
file encoding when content type starts with text/
(see UrlModuleSourceProvider.java#L172). There is created an official issue in Rhino GitHub #1232.
As a workaround you can remove entry text/javascript
from file content-types.properties and pass it to the Java through environment variable content.types.user.table
.
How to reproduce the problem
$ cat test.js
print('ěščřžýáíé')
$ grep text/javascript content-types.properties | wc -l
0
$ java -jar wrenidm/bundle/rhino-1.7.10.jar -require test.js
Ä¡ÄÅžýáÃé
$ java -Dcontent.types.user.table=content-types.properties -jar wrenidm/bundle/rhino-1.7.10.jar -require test.js
ěščřžýáíé