mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 03:37:34 -08:00
Avoid a few more rare exceptions
git-svn-id: https://zxing.googlecode.com/svn/trunk@2284 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b73efdfba1
commit
500872c9ff
|
@ -186,6 +186,9 @@ public final class Code93Reader extends OneDReader {
|
|||
for (int i = 0; i < length; i++) {
|
||||
char c = encoded.charAt(i);
|
||||
if (c >= 'a' && c <= 'd') {
|
||||
if (i >= length - 1) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
char next = encoded.charAt(i + 1);
|
||||
char decodedChar = '\0';
|
||||
switch (c) {
|
||||
|
|
|
@ -45,8 +45,10 @@ import java.io.InputStream;
|
|||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -129,18 +131,34 @@ public final class DecodeServlet extends HttpServlet {
|
|||
imageURIString = "http://" + imageURIString;
|
||||
}
|
||||
|
||||
URI imageURI;
|
||||
URL imageURL;
|
||||
try {
|
||||
imageURI = new URI(imageURIString);
|
||||
imageURL = new URI(imageURIString).toURL();
|
||||
} catch (URISyntaxException urise) {
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("URI was not valid: " + imageURIString);
|
||||
}
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
} catch (MalformedURLException mue) {
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("URI was not valid: " + imageURIString);
|
||||
}
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
}
|
||||
|
||||
HttpURLConnection connection;
|
||||
try {
|
||||
connection = (HttpURLConnection) imageURL.openConnection();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("URI could not be opened: " + imageURL);
|
||||
}
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
}
|
||||
|
||||
HttpURLConnection connection = (HttpURLConnection) imageURI.toURL().openConnection();
|
||||
connection.setAllowUserInteraction(false);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setConnectTimeout(5000);
|
||||
|
@ -182,7 +200,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
log.info("Decoding " + imageURI);
|
||||
log.info("Decoding " + imageURL);
|
||||
processStream(is, request, response);
|
||||
|
||||
} catch (IOException ioe) {
|
||||
|
|
Loading…
Reference in a new issue