Browse Source

Fix two places in demo where NPEs can occur on bad input

pull/965/head
David Yonge-Mallo 10 years ago
parent
commit
6ee4079b83
2 changed files with 6 additions and 2 deletions
  1. +2
    -2
      java/demo/src/com/google/phonenumbers/PhoneNumberParserServlet.java
  2. +4
    -0
      java/release_notes.txt

+ 2
- 2
java/demo/src/com/google/phonenumbers/PhoneNumberParserServlet.java View File

@ -103,7 +103,7 @@ public class PhoneNumberParserServlet extends HttpServlet {
StringBuilder output;
resp.setContentType("text/html");
resp.setCharacterEncoding(UTF_8.name());
if (fileContents.length() == 0) {
if (fileContents == null || fileContents.length() == 0) {
// Redirect to a URL with the given input encoded in the query parameters.
Locale geocodingLocale = new Locale(languageCode, regionCode);
resp.sendRedirect(getPermaLinkURL(phoneNumber, defaultCountry, geocodingLocale,
@ -196,7 +196,7 @@ public class PhoneNumberParserServlet extends HttpServlet {
absoluteURL ? "http://libphonenumber.appspot.com/phonenumberparser" : "/phonenumberparser");
try {
permaLink.append("?number=" + URLEncoder.encode(phoneNumber, UTF_8.name()));
if (!defaultCountry.isEmpty()) {
if (defaultCountry != null && !defaultCountry.isEmpty()) {
permaLink.append("&country=" + URLEncoder.encode(defaultCountry, UTF_8.name()));
}
if (!geocodingLocale.getLanguage().equals(ENGLISH.getLanguage()) ||


+ 4
- 0
java/release_notes.txt View File

@ -1,3 +1,7 @@
Pending changes
Code changes:
- Fix two places in demo where NPEs can occur on bad input
Jan 28, 2016: libphonenumber-7.2.4
Metadata changes:
- Updated phone metadata for region code(s):


Loading…
Cancel
Save