Allow the + character in phone numbers. In the same time, fix a bug where other non...
authorleppoc <leppoc@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 19 Dec 2008 16:24:20 +0000 (16:24 +0000)
committerleppoc <leppoc@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 19 Dec 2008 16:24:20 +0000 (16:24 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@795 59b500cc-1b3d-0410-9834-0bbf25fbcc57

zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Generator.java
zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Validators.java

index 94b0662..05cb0c0 100644 (file)
@@ -181,7 +181,7 @@ public class Generator implements EntryPoint {
     result += "x";
     result += sizeY;
     result += "&chl=";
-    result += URL.encode(content);
+    result += URL.encodeComponent(content);
     return result;
   }
   
index 51646bf..99458e4 100644 (file)
@@ -24,11 +24,11 @@ package com.google.zxing.web.generator.client;
  */
 public final class Validators {
   public static String filterNumber(String number) {
-    return number.replaceAll("[ +\\.,\\-\\(\\)]", "");
+    return number.replaceAll("[ \\.,\\-\\(\\)]", "");
   }
   
   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.");
     }
   }