From: Charlie G. <cha...@gm...> - 2006-12-31 18:50:30
|
URLDecoder.decode(String url, String encoding) didn't appear until Java 1.4 so this doesn't compile for 1.2 or 1.3. They only have URLDecoder.decode(String url) Since the bug fixed with that encoding argument is in the 1.2 and 1.3 versions, I'm thinking we should revert this for trunk, but merge it over to the 2.3 branch where we can use Java 1.4 methods. Sound good? Charlie On 12/28/06, otm...@us... <otm...@us...> wrote: > Revision: 3031 > http://svn.sourceforge.net/jython/?rev=3031&view=rev > Author: otmarhumbel > Date: 2006-12-28 07:10:49 -0800 (Thu, 28 Dec 2006) > > Log Message: > ----------- > use URLDecoder instead of decoding "by hand" > > Modified Paths: > -------------- > trunk/jython/src/org/python/core/PySystemState.java > > Modified: trunk/jython/src/org/python/core/PySystemState.java > =================================================================== > --- trunk/jython/src/org/python/core/PySystemState.java 2006-12-28 15:02:02 UTC (rev 3030) > +++ trunk/jython/src/org/python/core/PySystemState.java 2006-12-28 15:10:49 UTC (rev 3031) > @@ -9,7 +9,9 @@ > import java.io.FilterInputStream; > import java.io.IOException; > import java.io.InputStream; > +import java.io.UnsupportedEncodingException; > import java.net.URL; > +import java.net.URLDecoder; > import java.security.AccessControlException; > import java.util.Enumeration; > import java.util.Hashtable; > @@ -31,7 +33,6 @@ > > private static final String JAR_URL_PREFIX = "jar:file:"; > private static final String JAR_SEPARATOR = "!"; > - private static final String URL_BLANK_REPLACEMENT = "%20"; > > private static final String PYTHON_CACHEDIR = "python.cachedir"; > protected static final String PYTHON_CACHEDIR_SKIP = "python.cachedir.skip"; > @@ -668,20 +669,14 @@ > URL url = thisClass.getResource(className + ".class"); > // we expect an URL like jar:file:/install_dir/jython.jar!/org/python/core/PySystemState.class > if (url != null) { > - String urlString = url.toString(); > - int jarSeparatorIndex = urlString.indexOf(JAR_SEPARATOR); > - if (urlString.startsWith(JAR_URL_PREFIX) && jarSeparatorIndex > 0) { > - jarFileName = urlString.substring(JAR_URL_PREFIX.length(), jarSeparatorIndex); > - // handle directories containing blanks > - // we can't use String.replaceAll before java 1.4, so instead of the obvious: > - // jarFileName = jarFileName.replaceAll(URL_BLANK_REPLACEMENT, " "); > - // apply repeated substitutions, which should be safe in this case > - int URL_BLANK_LOCATION = jarFileName.indexOf(URL_BLANK_REPLACEMENT); > - while (URL_BLANK_LOCATION >= 0) { > - jarFileName = jarFileName.substring(0, URL_BLANK_LOCATION) + " " + > - jarFileName.substring(URL_BLANK_LOCATION + URL_BLANK_REPLACEMENT.length()); > - URL_BLANK_LOCATION = jarFileName.indexOf(URL_BLANK_REPLACEMENT); > + try { > + String urlString = URLDecoder.decode(url.toString(), "UTF-8"); > + int jarSeparatorIndex = urlString.indexOf(JAR_SEPARATOR); > + if (urlString.startsWith(JAR_URL_PREFIX) && jarSeparatorIndex > 0) { > + jarFileName = urlString.substring(JAR_URL_PREFIX.length(), jarSeparatorIndex); > } > + } catch (UnsupportedEncodingException e) { > + // this is VERY unlikely - forget about standalone if it happens > } > } > return jarFileName; > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Jython-checkins mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-checkins > |