From 2ecca4f2d5075168741b6d56e999b1d21c2332a4 Mon Sep 17 00:00:00 2001 From: vikrama Date: Thu, 17 Jun 2010 05:24:42 +0000 Subject: [PATCH 1/1] Escape the semicolons: this was easier than I imagined. Tested with an ssid containing multiple semicolons. Also some minor code cleanups. Still to be done: 1. Rename 'nopass' to something cleaner, so it looks crisp in Android's Barcode Scanner UI. git-svn-id: http://zxing.googlecode.com/svn/trunk@1441 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../zxing/web/generator/client/WifiGenerator.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/WifiGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/WifiGenerator.java index 3702448b..1c8a6bc1 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/WifiGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/WifiGenerator.java @@ -32,12 +32,11 @@ public class WifiGenerator implements GeneratorSource { Grid table = null; TextBox ssid = new TextBox(); TextBox password = new TextBox(); - // Do not allow multiple selections, thus the false - ListBox networkType = new ListBox(false); + final boolean multipleSelections = false; + ListBox networkType = new ListBox(multipleSelections); TextBox[] widgets = {ssid, password }; - public WifiGenerator(ChangeListener changeListener, - KeyPressHandler keyListener) { + public WifiGenerator(ChangeListener changeListener, KeyPressHandler keyListener) { networkType.addItem("WEP", "WEP"); networkType.addItem("WPA/WPA2", "WPA"); networkType.addItem("No encryption", "nopass"); @@ -58,15 +57,12 @@ public class WifiGenerator implements GeneratorSource { String networkType = getNetworkTypeField(); // Build the output with obtained data. - // note that some informations may just be "" if they were not specified. - //return getVCard(name, company, tel, url, email, address, memo); return getWifiString(ssid, password, networkType); } private String getWifiString(String ssid, String password, String type) { StringBuilder output = new StringBuilder(); output.append("WIFI:"); - // TODO(vikrama): Escape the semicolons in ssid and password output.append("S:").append(ssid).append(';'); maybeAppend(output, "T:", type); maybeAppend(output, "P:", password); @@ -88,10 +84,7 @@ public class WifiGenerator implements GeneratorSource { if (input.contains("\n")) { throw new GeneratorException(name + " field must not contain \\n characters."); } - if (input.contains(";")) { - // TODO(viki): Escape semicolons and colons - throw new GeneratorException(name + " field must not contains ; characters"); - } + input = input.replace(";", "\\;"); return input; } -- 2.20.1