Escape ;, /, \ too

git-svn-id: https://zxing.googlecode.com/svn/trunk@1626 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-10-14 18:25:40 +00:00
parent e9ae6dd4d3
commit 684440dcfe

View file

@ -61,7 +61,7 @@ public class WifiGenerator implements GeneratorSource {
} }
private String getWifiString(String ssid, String password, String type) { private String getWifiString(String ssid, String password, String type) {
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder(100);
output.append("WIFI:"); output.append("WIFI:");
output.append("S:").append(ssid).append(';'); output.append("S:").append(ssid).append(';');
maybeAppend(output, "T:", type); maybeAppend(output, "T:", type);
@ -85,6 +85,9 @@ public class WifiGenerator implements GeneratorSource {
throw new GeneratorException(name + " field must not contain \\n characters."); throw new GeneratorException(name + " field must not contain \\n characters.");
} }
input = input.replace(";", "\\;"); input = input.replace(";", "\\;");
input = input.replace(":", "\\:");
input = input.replace("\\", "\\\\");
input = input.replace("/", "\\/");
return input; return input;
} }
@ -101,8 +104,7 @@ public class WifiGenerator implements GeneratorSource {
} }
private String getNetworkTypeField() throws GeneratorException { private String getNetworkTypeField() throws GeneratorException {
String input = networkType.getValue(networkType.getSelectedIndex()); return networkType.getValue(networkType.getSelectedIndex());
return input;
} }
public Grid getWidget() { public Grid getWidget() {
@ -124,9 +126,15 @@ public class WifiGenerator implements GeneratorSource {
} }
public void validate(Widget widget) throws GeneratorException { public void validate(Widget widget) throws GeneratorException {
if (widget == ssid) getSsidField(); if (widget == ssid) {
if (widget == password) getPasswordField(); getSsidField();
if (widget == networkType) getNetworkTypeField(); }
if (widget == password) {
getPasswordField();
}
if (widget == networkType) {
getNetworkTypeField();
}
} }
public void setFocus() { public void setFocus() {