Issue #142 : fix escaping of %f / %t

This commit is contained in:
Sean Owen 2014-05-10 16:19:46 +01:00
parent 7a0ff2305f
commit 5a07783224
2 changed files with 4 additions and 5 deletions

View file

@ -467,19 +467,18 @@ public abstract class ResultHandler {
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding // can't happen; UTF-8 is always supported. Continue, I guess, without encoding
} }
String url = text; String url = customProductSearch;
if (rawResult != null) { if (rawResult != null) {
// Replace %f but only if it doesn't seem to be a hex escape sequence. This remains // Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
// problematic but avoids the more surprising problem of breaking escapes // problematic but avoids the more surprising problem of breaking escapes
url = url.replace("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString()); url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
if (url.contains("%t")) { if (url.contains("%t")) {
ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult); ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
url = url.replace("%t", parsedResultAgain.getType().toString()); url = url.replace("%t", parsedResultAgain.getType().toString());
} }
} }
// Replace %s last as it might contain itself %f or %t // Replace %s last as it might contain itself %f or %t
url = customProductSearch.replace("%s", url); return url.replace("%s", text);
return url;
} }
} }

View file

@ -43,7 +43,7 @@
</parent> </parent>
<properties> <properties>
<gwt.version>2.6.0</gwt.version> <gwt.version>2.6.1-rc2</gwt.version>
</properties> </properties>
<build> <build>