Permalink
Browse files

Fix issue #163 by encoding spaces as + and encoding + as %2B

  • Loading branch information...
ndw committed Aug 15, 2014
1 parent b3f2651 commit 20baa34e36750c3623173cd5061b00a91059d3f2
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/com/xmlcalabash/library/WWWFormURLEncode.java
@@ -137,7 +137,7 @@ public void processAttribute(XdmNode node) throws SaxonApiException {
private String encode(String src) {
String genDelims = ":/?#[]@";
- String subDelims = "!$'()*+,;="; // N.B. NO &!
+ String subDelims = "!$'()*,;="; // N.B. NO & and no + !
String unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~";
String okChars = genDelims + subDelims + unreserved;
@@ -149,7 +149,11 @@ private String encode(String src) {
if (okChars.indexOf(bytes[pos]) >= 0) {
encoded += (char) bytes[pos];
} else {
- encoded += String.format("%%%02X", bytes[pos]);
+ if (bytes[pos] == ' ') {
+ encoded += "+";
+ } else {
+ encoded += String.format("%%%02X", bytes[pos]);
+ }
}
}
} catch (UnsupportedEncodingException uee) {

0 comments on commit 20baa34

Please sign in to comment.