From 57dc2ca7422fcbba79eb10a40f1db93fe7a36ba1 Mon Sep 17 00:00:00 2001 From: "srowen@gmail.com" Date: Tue, 23 Apr 2013 09:08:26 +0000 Subject: [PATCH] Fix and improve last commit for data URIs git-svn-id: https://zxing.googlecode.com/svn/trunk@2683 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../src/com/google/zxing/web/DecodeServlet.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zxingorg/src/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/com/google/zxing/web/DecodeServlet.java index 5a235912c..b64a9f4fb 100644 --- a/zxingorg/src/com/google/zxing/web/DecodeServlet.java +++ b/zxingorg/src/com/google/zxing/web/DecodeServlet.java @@ -123,15 +123,15 @@ public final class DecodeServlet extends HttpServlet { imageURIString = imageURIString.trim(); - if (!(imageURIString.startsWith("http://") || imageURIString.startsWith("https://"))) { - imageURIString = "http://" + imageURIString; - } - URI imageURI; try { imageURI = new URI(imageURIString); - } catch (URISyntaxException ignored) { - log.info("URI was not valid: " + imageURIString); + // Assume http: if not specified + if (imageURI.getScheme() == null) { + imageURI = new URI("http://" + imageURIString); + } + } catch (URISyntaxException urise) { + log.info("URI " + imageURIString + " was not valid: " + urise); response.sendRedirect("badurl.jspx"); return; } @@ -144,8 +144,8 @@ public final class DecodeServlet extends HttpServlet { } catch (IOException ioe) { log.info(ioe.toString()); response.sendRedirect("badurl.jspx"); - return; } + return; } URL imageURL;