Allow the + character in phone numbers. In the same time, fix a bug where other non allowed characters (such as /, or &) in url attributes would generate a non valid url.

git-svn-id: https://zxing.googlecode.com/svn/trunk@795 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
leppoc 2008-12-19 16:24:20 +00:00
parent 48480eba95
commit 280bb12e34
2 changed files with 3 additions and 3 deletions

View file

@ -181,7 +181,7 @@ public class Generator implements EntryPoint {
result += "x"; result += "x";
result += sizeY; result += sizeY;
result += "&chl="; result += "&chl=";
result += URL.encode(content); result += URL.encodeComponent(content);
return result; return result;
} }

View file

@ -24,11 +24,11 @@ package com.google.zxing.web.generator.client;
*/ */
public final class Validators { public final class Validators {
public static String filterNumber(String number) { public static String filterNumber(String number) {
return number.replaceAll("[ +\\.,\\-\\(\\)]", ""); return number.replaceAll("[ \\.,\\-\\(\\)]", "");
} }
public static void validateNumber(String number) throws GeneratorException { public static void validateNumber(String number) throws GeneratorException {
if (!number.matches("[0-9]+")) { if (!number.matches("\\+?[0-9]+")) {
throw new GeneratorException("Phone number must be digits only."); throw new GeneratorException("Phone number must be digits only.");
} }
} }