AdoptOpenJDK / IcedTea-Web

The new home for IcedTea-Web
Other
225 stars 87 forks source link

Encoding UTF-8 not well supported for jnlp(xml) file on Windows #190

Closed douph1 closed 4 years ago

douph1 commented 5 years ago

I have some strange char on Windows into Desktop shortcut, Windows Menu and Splas screen due to somme non ascii char in jnlp

For the demo purpose I have added é è and à in some xml attribut Sample jnlp: https://apoweb-preprod-integration.phmd.net/preprod_integration/version.jnlp This jnlp display a JFrame with java version information.

No content-type return by the web server: < HTTP/1.1 200 OK < Date: Thu, 18 Apr 2019 14:20:41 GMT < Server: Apache-Coyote/1.1 < Accept-Ranges: bytes < ETag: W/"759-1555596356000" < Last-Modified: Thu, 18 Apr 2019 14:05:56 GMT < Content-Type: application/x-java-jnlp-file < Content-Length: 759

And jnlp file begin with UTF-8 : <?xml version="1.0" encoding="UTF-8"?>

 Desktop shorcut name create is called : Version title é (Version).lnk Idem for StartUp menu : Uninstall Version title é.lnk

and we can see the accented char are not well displayed in Splas screen too

PS: on Linux, the Shorcut name is good ( with accent )

douph1 commented 5 years ago

just tried with Oracle jre1.8.0_201 wich handle desktop and startmenu file name correctly "Version title é"

douph1 commented 5 years ago

This has for effect to break clearing from shortcuts wich looking for file with utf-8 char but dont find it

[adminup][ITW-JAVAWS][WARNING_ALL][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.clearCache(CacheUtil.java:188)] NETX Thread# 5b480cf9, name main Clearing cache for: file:/C:/Users/adminup/Downloads/version.jnlp
[adminup][ITW-JAVAWS][MESSAGE_ALL][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.clearCache(CacheUtil.java:204)] NETX Thread# 5b480cf9, name main Alerting: 1 of files
[adminup][ITW-JAVAWS][MESSAGE_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil$1.accept(CacheUtil.java:222)] NETX Thread# 5b480cf9, name main marked for deletion: C:\Users\adminup\.cache\icedtea-web\cache\1\https\apoweb-preprod-integration.phmd.net\preprod_integration\Version.jar.info
[adminup][ITW-JAVAWS][ERROR_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:251)] NETX Thread# 5b480cf9, name main Clearing Windows shortcuts
[adminup][ITW-JAVAWS][MESSAGE_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:272)] NETX Thread# 5b480cf9, name main Deleting item = C:\Users\adminup/Desktop/Version title é (Version).lnk
[adminup][ITW-JAVAWS][ERROR_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.util.FileUtils.recursiveDelete(FileUtils.java:518)] NETX Thread# 5b480cf9, name main Deleting: C:\Users\adminup\Desktop\Version title é (Version).lnk
[adminup][ITW-JAVAWS][ERROR_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:277)] NETX Thread# 5b480cf9, name main
java.io.IOException: Unable to delete file: C:\Users\adminup\Desktop\Version title é (Version).lnk
    at net.sourceforge.jnlp.util.FileUtils.recursiveDelete(FileUtils.java:532)
    at net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:275)
    at net.sourceforge.jnlp.cache.CacheUtil.clearCache(CacheUtil.java:228)
    at net.sourceforge.jnlp.runtime.Boot.init(Boot.java:373)
    at net.sourceforge.jnlp.runtime.JnlpBoot.run(JnlpBoot.java:58)
    at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:270)
    at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:63)
    at java.security.AccessController.doPrivileged(Native Method)
    at net.sourceforge.jnlp.runtime.Boot.main(Boot.java:210)
[adminup][ITW-JAVAWS][MESSAGE_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:272)] NETX Thread# 5b480cf9, name main Deleting item = C:\Users\adminup/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Version menu à/Version title é.lnk
[adminup][ITW-JAVAWS][ERROR_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.util.FileUtils.recursiveDelete(FileUtils.java:518)] NETX Thread# 5b480cf9, name main Deleting: C:\Users\adminup\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Version menu à\Version title é.lnk
[adminup][ITW-JAVAWS][ERROR_DEBUG][Thu Apr 18 17:19:11 CEST 2019][net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:277)] NETX Thread# 5b480cf9, name main
java.io.IOException: Unable to delete file: C:\Users\adminup\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Version menu à\Version title é.lnk
    at net.sourceforge.jnlp.util.FileUtils.recursiveDelete(FileUtils.java:532)
    at net.sourceforge.jnlp.cache.CacheUtil.removeWindowsShortcuts(CacheUtil.java:275)
    at net.sourceforge.jnlp.cache.CacheUtil.clearCache(CacheUtil.java:228)
    at net.sourceforge.jnlp.runtime.Boot.init(Boot.java:373)
    at net.sourceforge.jnlp.runtime.JnlpBoot.run(JnlpBoot.java:58)
    at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:270)
    at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:63)
    at java.security.AccessController.doPrivileged(Native Method)
    at net.sourceforge.jnlp.runtime.Boot.main(Boot.java:210)
judovana commented 5 years ago

It do not look right - the jnlp file vendor looks weird:

Version desc è

...

e and a ? Really?

Maybe server is changing the encoding on the fly. Generally if there is any other encoding then utf8 anywhere in Icedtea-web code, then it is wrong.

douph1 commented 5 years ago

It do not look right - the jnlp file vendor looks weird:

Yes, the file is weird voluntarily (accent letters) to show that UTF-8 char are not handled properly as said

For the demo purpose I have added é è and à in some xml attribut

Maybe server is changing the encoding on the fly.

No Try to detect encoding with "file" on unix

doussot@PC-TEC-12:~$ curl -s https://apoweb-preprod-integration.phmd.net/preprod_integration/version.jnlp | grep "title" | file -
/dev/stdin: HTML document, UTF-8 Unicode text
doussot@PC-TEC-12:~$ curl -s https://apoweb-preprod-integration.phmd.net/preprod_integration/version.jnlp | grep "submenu" | file -
/dev/stdin: UTF-8 Unicode text
doussot@PC-TEC-12:~$ curl -s https://apoweb-preprod-integration.phmd.net/preprod_integration/version.jnlp | grep description | file -
/dev/stdin: UTF-8 Unicode text

and you can read http header too, it dont indicate any encoding

Content-Type: application/x-java-jnlp-file

janakmulani commented 4 years ago

Played around a bit with the jnlp file on windows and found that the characters you see depend on the encoding used when saving the jnlp file on your machine. On my windows machine I start your app using the URL https://apoweb-preprod-integration.phmd.net/preprod_integration/version.jnlp. On my machine version.jnlp is saved in UTF-8 format and I see the proper name with accented character for Desktop Icon and start menu entry. DesktopIcon

However, if I open the jnlp file and save it after encoding it in ANSI and removing the href (so that it will not download the jnlp file from server) VersionJnlpANSI

then I get the funny character in desktop Icon :

DesktopIcon-ANSI

Jamila891 commented 4 years ago

@douph1 did the last message help you to solve the problem? If yes, we would close this issue.

douph1 commented 4 years ago

I had saved it correctly in UTF-8 (vim linux user here). Has you as seen, "file" command confirmed this was utf-8 I will try one more time.

douph1 commented 4 years ago

see the original sample version.jnlp.txt

douph1 commented 4 years ago

Just trying with latest OpenJDK8U-jdk_x64_windows_hotspot_8u265b01.msi bundled with icedtea1.8.3 .. same : accent broken OpenWebStart 1.2.1 : encoding correct openwebstart_1 2 1

and same for Start Menu start_menu

Is OpenWebStart 1.2.1 bundled from master branch (aka pre 2.0.0 , maybe 2.0.0-alpha15 tag ) ? If yes, does an encoding fix was made part of IcedTea or OpenWebStart ?

douph1 commented 4 years ago

Just tested master branch and the encoding bug seems fixed for the next 2.0.0