mirror of
https://github.com/zxing/zxing.git
synced 2024-11-13 14:34:08 -08:00
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:
parent
48480eba95
commit
280bb12e34
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue