Fix and improve last commit for data URIs

git-svn-id: https://zxing.googlecode.com/svn/trunk@2683 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-04-23 09:08:26 +00:00
parent 13d97af689
commit 57dc2ca742

View file

@ -123,15 +123,15 @@ public final class DecodeServlet extends HttpServlet {
imageURIString = imageURIString.trim(); imageURIString = imageURIString.trim();
if (!(imageURIString.startsWith("http://") || imageURIString.startsWith("https://"))) {
imageURIString = "http://" + imageURIString;
}
URI imageURI; URI imageURI;
try { try {
imageURI = new URI(imageURIString); imageURI = new URI(imageURIString);
} catch (URISyntaxException ignored) { // Assume http: if not specified
log.info("URI was not valid: " + imageURIString); if (imageURI.getScheme() == null) {
imageURI = new URI("http://" + imageURIString);
}
} catch (URISyntaxException urise) {
log.info("URI " + imageURIString + " was not valid: " + urise);
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
return; return;
} }
@ -144,8 +144,8 @@ public final class DecodeServlet extends HttpServlet {
} catch (IOException ioe) { } catch (IOException ioe) {
log.info(ioe.toString()); log.info(ioe.toString());
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
return;
} }
return;
} }
URL imageURL; URL imageURL;