|
patch for ;jsessionid: msg#00015java.enhydra.general
Hi, this patch fixes a problem with appending the ;jsessionid to non-*.po URLs. BTW, I would be glad to have CVS write access so I could commit such things directly in. Can someone give me that? --- Enhydra/modules/Enhydra/src/com/lutris/appserver/server/StandardAppUtil.java.original 2002-10-30 14:02:45.000000000 +0100 +++ Enhydra/modules/Enhydra/src/com/lutris/appserver/server/StandardAppUtil.java 2002-11-05 11:03:59.000000000 +0100 @@ -1,4 +1,4 @@ - + /* * Enhydra Java Application Server Project * @@ -165,38 +165,52 @@ * non-mathematicians :-) the URL contains the character sequence * <code>.po</code>. * <br> - * TODO: Implement a better check + * A safety check has been added by Petr Stehlik on 2002/11/05: + * First, it strips a query and fragment parts of the URL, since + * both the query and the fragment may contain ".po" that + * confuses the original algorithm. + * <br> + * Example: <code>http://www.server.org/path/file.html?query=page.po</code> + * <br> + * The function now correctly returns false for the URL above. * * @param url The url to check * @return True if the URL points to a PO, false otherwise */ public static boolean pointsToPO(String url) { - int idx = url.indexOf(".po"); + // first, strip any query and fragment + int idx = url.indexOf('?'); // is there a query? + if (idx == -1) { + idx = url.indexOf('#'); // or is there a fragment? + } + if (idx > 0) { + url = url.substring(0, idx); // strip them! + } + + // now check for the ".po" (should be at the end of the URL) + idx = url.indexOf(".po"); if (idx == -1) { return false; } if (idx == url.length()-3) { return true; } - switch (url.charAt(idx+3)) { - case '?': - case '#': - return true; - case '/': - // A bit more difficult: Need to decide if it's in the - // the server or URI part of the URL. - try { - URL u = new URL(url); - int i = u.getFile().indexOf(".po"); - return (i != -1); - } catch (MalformedURLException e) { - // url doesn't contain a schema and/or server - // part, so it must be relative. OK, found a PO. - return true; - } - default: - return false; + // if it's not at the end of the URL then decide if it's in the URI + if (url.charAt(idx+3) == '/') { + // A bit more difficult: Need to decide if it's in the + // the server or URI part of the URL. + try { + URL u = new URL(url); + int i = u.getFile().indexOf(".po"); + return (i != -1); + } catch (MalformedURLException e) { + // url doesn't contain a schema and/or server + // part, so it must be relative. OK, found a PO. + return true; + } } + + return false; }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | bug tracking, Ricardo Trindade |
|---|---|
| Next by Date: | Enhydra 3.1 and Xerces 1.3.1, Tom Gates |
| Previous by Thread: | bug tracking, Ricardo Trindade |
| Next by Thread: | Enhydra 3.1 and Xerces 1.3.1, Tom Gates |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |