Need to use sanitized user names in temporary directory construction

49 views
Skip to first unread message

Logi Vidarsson

unread,
Mar 26, 2019, 10:22:46 AM3/26/19
to dcm4che
Good morning

Thanks again for Weasis, love this light-weight yet powerful viewer.

Had a buddy who used her full name (wonderful French é and all) as her user name on a Windows laptop.

This caused no problems, except when time came to generate reformats, whereas the reformat process would hang when creating temporary files.

Turns out that if you sanitize the temporary directory name (by removing any non-ASCII characters) there is no hang, and reformats are generated as expected.

This I accomplished by changing line 72 in  weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/gui/util/AppProperties.java from

APP_TEMP_DIR = new File(tdir, "weasis-" + System.getProperty("user.name", "tmp") + "." //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ System.getProperty("weasis.source.id", UNKNOWN)); //$NON-NLS-1$

to

        // need to cleanse the user name of any non-ascii charachters as otherwise temporary files get mis-placed
        String userName = System.getProperty("user.name", "tmp");
        userName = userName.replaceAll("[^\\x00-\\x7F]", "");
        
        APP_TEMP_DIR = new File(tdir, "weasis-" + userName  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            + System.getProperty("weasis.source.id", "unknown")); //$NON-NLS-1$ //$NON-NLS-2$

May this prevent hangs on your end too;)

Best

Logi


Nicolas Roduit

unread,
Apr 8, 2019, 5:22:55 AM4/8/19
to dcm4che
I open an issue. The problem is located in the native OpenCV lib. The application should support any path.
Reply all
Reply to author
Forward
0 new messages