Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 94821 invoked from network); 21 May 2010 10:54:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 May 2010 10:54:42 -0000 Received: (qmail 82847 invoked by uid 500); 21 May 2010 10:54:41 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 82799 invoked by uid 500); 21 May 2010 10:54:40 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 82790 invoked by uid 99); 21 May 2010 10:54:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 May 2010 10:54:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 May 2010 10:54:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 69F0D238896F; Fri, 21 May 2010 10:54:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r946970 - /incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java Date: Fri, 21 May 2010 10:54:19 -0000 To: chemistry-commits@incubator.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100521105419.69F0D238896F@eris.apache.org> Author: fmui Date: Fri May 21 10:54:19 2010 New Revision: 946970 URL: http://svn.apache.org/viewvc?rev=946970&view=rev Log: another tweak to solve all encoding issues (CMIS-210) Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java?rev=946970&r1=946969&r2=946970&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java Fri May 21 10:54:19 2010 @@ -61,6 +61,8 @@ public class BrowseServlet extends HttpS private static final String CONTEXT_PREFIX = "{ctx}"; private static final String PARAM_URL = "url"; + private static final int PARAM_URL_MIN_LEN = PARAM_URL.length() + "=".length() + "http".length() + "://".length() + + 1; private static final String INIT_PARAM_AUXROOT = "auxroot"; private static final String INIT_PARAM_ALLOW = "allow"; private static final String INIT_PARAM_STYLESHEET = "stylesheet:"; @@ -128,7 +130,8 @@ public class BrowseServlet extends HttpS */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - if ((req.getQueryString() == null) || (!req.getQueryString().startsWith(PARAM_URL + "="))) { + if ((req.getQueryString() == null) || (!req.getQueryString().startsWith(PARAM_URL + "=")) + || (req.getQueryString().length() < PARAM_URL_MIN_LEN)) { printInput(req, resp); return; } @@ -140,7 +143,14 @@ public class BrowseServlet extends HttpS * Main method of the browser. */ protected void doBrowse(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - String browseUrl = URLDecoder.decode(req.getQueryString().substring(PARAM_URL.length() + 1), "UTF-8"); + String browseUrl = req.getQueryString().substring(PARAM_URL.length() + 1); + + // check if decoding is necessary + // (if the char after 'http' or 'https' is not a colon, then it must be + // decoded) + if (browseUrl.charAt(4) != ':' && browseUrl.charAt(5) != ':') { + browseUrl = URLDecoder.decode(browseUrl, "UTF-8"); + } // check URL if (!browseUrl.matches(fAllow)) {