Fix and improve last commit for data URIs
git-svn-id: https://zxing.googlecode.com/svn/trunk@2683 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/zxingorg/src/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/com/google/zxing/web/DecodeServlet.java
index 5a23591..b64a9f4 100644
--- a/zxingorg/src/com/google/zxing/web/DecodeServlet.java
+++ b/zxingorg/src/com/google/zxing/web/DecodeServlet.java
@@ -123,15 +123,15 @@
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 @@
} catch (IOException ioe) {
log.info(ioe.toString());
response.sendRedirect("badurl.jspx");
- return;
}
+ return;
}
URL imageURL;