mirror of
https://github.com/zxing/zxing.git
synced 2024-11-13 14:34:08 -08:00
Fix a typo or two from the last commit
git-svn-id: https://zxing.googlecode.com/svn/trunk@1345 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
87b0b9c8aa
commit
5e026d8535
|
@ -90,8 +90,8 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
|
|
||||||
// No real reason to let people upload more than a 2MB image
|
// No real reason to let people upload more than a 2MB image
|
||||||
private static final long MAX_IMAGE_SIZE = 2000000L;
|
private static final long MAX_IMAGE_SIZE = 2000000L;
|
||||||
// No real reason to deal with more than maybe 2.5 megapixels
|
// No real reason to deal with more than maybe 2 megapixels
|
||||||
private static final int MAX_PIXELS = 1 << 16;
|
private static final int MAX_PIXELS = 1 << 21;
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(DecodeServlet.class.getName());
|
private static final Logger log = Logger.getLogger(DecodeServlet.class.getName());
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
String imageURIString = request.getParameter("u");
|
String imageURIString = request.getParameter("u");
|
||||||
if (imageURIString == null || imageURIString.length() == 0) {
|
if (imageURIString == null || imageURIString.length() == 0) {
|
||||||
|
log.fine("URI was empty");
|
||||||
response.sendRedirect("badurl.jspx");
|
response.sendRedirect("badurl.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +160,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
try {
|
try {
|
||||||
imageURI = new URI(imageURIString);
|
imageURI = new URI(imageURIString);
|
||||||
} catch (URISyntaxException urise) {
|
} catch (URISyntaxException urise) {
|
||||||
|
log.fine("URI was not valid: " + imageURIString);
|
||||||
response.sendRedirect("badurl.jspx");
|
response.sendRedirect("badurl.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +178,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
getResponse = client.execute(getRequest);
|
getResponse = client.execute(getRequest);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
// Thrown if hostname is bad or null
|
// Thrown if hostname is bad or null
|
||||||
|
log.fine(iae.toString());
|
||||||
getRequest.abort();
|
getRequest.abort();
|
||||||
response.sendRedirect("badurl.jspx");
|
response.sendRedirect("badurl.jspx");
|
||||||
return;
|
return;
|
||||||
|
@ -185,16 +188,19 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
// javax.net.ssl.SSLPeerUnverifiedException,
|
// javax.net.ssl.SSLPeerUnverifiedException,
|
||||||
// org.apache.http.NoHttpResponseException,
|
// org.apache.http.NoHttpResponseException,
|
||||||
// org.apache.http.client.ClientProtocolException,
|
// org.apache.http.client.ClientProtocolException,
|
||||||
|
log.fine(ioe.toString());
|
||||||
getRequest.abort();
|
getRequest.abort();
|
||||||
response.sendRedirect("badurl.jspx");
|
response.sendRedirect("badurl.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getResponse.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) {
|
if (getResponse.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) {
|
||||||
|
log.fine("Unsuccessful return code: " + getResponse.getStatusLine().getStatusCode());
|
||||||
response.sendRedirect("badurl.jspx");
|
response.sendRedirect("badurl.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isSizeOK(getResponse)) {
|
if (!isSizeOK(getResponse)) {
|
||||||
|
log.fine("Too large");
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -220,6 +226,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||||
|
log.fine("File upload was not multipart");
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -240,12 +247,14 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.fine("Too large");
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (FileUploadException fue) {
|
} catch (FileUploadException fue) {
|
||||||
|
log.fine(fue.toString());
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,21 +267,25 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
try {
|
try {
|
||||||
image = ImageIO.read(is);
|
image = ImageIO.read(is);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
log.fine(ioe.toString());
|
||||||
// Includes javax.imageio.IIOException
|
// Includes javax.imageio.IIOException
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
} catch (CMMException cmme) {
|
} catch (CMMException cmme) {
|
||||||
|
log.fine(cmme.toString());
|
||||||
// Have seen this in logs
|
// Have seen this in logs
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
|
log.fine(iae.toString());
|
||||||
// Have seen this in logs for some JPEGs
|
// Have seen this in logs for some JPEGs
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (image == null ||
|
if (image == null ||
|
||||||
image.getHeight() <= 1 || image.getWidth() >= 1 ||
|
image.getHeight() <= 1 || image.getWidth() <= 1 ||
|
||||||
image.getHeight() * image.getWidth() > MAX_PIXELS) {
|
image.getHeight() * image.getWidth() > MAX_PIXELS) {
|
||||||
|
log.fine("Dimensions too large: " + image.getWidth() + 'x' + image.getHeight());
|
||||||
response.sendRedirect("badimage.jspx");
|
response.sendRedirect("badimage.jspx");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue