From 356bf78059d4f77552ae073543dbd867c9a1325d Mon Sep 17 00:00:00 2001 From: Ananya Saxena Date: Mon, 1 May 2017 09:59:13 -0700 Subject: [PATCH] allow '=' in query parameter value --- .../com/google/api/client/http/UrlEncodedParser.java | 9 +++++++-- .../com/google/api/client/http/UrlEncodedParserTest.java | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java index 8dc1c9246..52209740b 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java +++ b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java @@ -196,8 +196,13 @@ public static void parse(Reader reader, Object data) throws IOException { } break; case '=': - // finished with name, now read value - readingName = false; + if (readingName) { + // finished with name, now read value + readingName = false; + } else { + // '=' is in the value + valueWriter.write(read); + } break; default: // read one more character diff --git a/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedParserTest.java b/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedParserTest.java index 8042ecf17..7659e4551 100644 --- a/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedParserTest.java +++ b/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedParserTest.java @@ -112,9 +112,9 @@ public Generic set(String fieldName, Object value) { public void testParse_simple() { Simple actual = new Simple(); UrlEncodedParser.parse( - "v=ignore&v=ignore2&q=1&a=x&b=y&c=z&q=2&undeclared=0&o=object&r=a1&r=a2", actual); + "v=ignore&v=ignore2&q=1&a=x=&b=y&c=z&q=2&undeclared=0&o=object&r=a1&r=a2", actual); Simple expected = new Simple(); - expected.a = "x"; + expected.a = "x="; expected.b = "y"; expected.c = "z"; expected.q = new ArrayList(Arrays.asList("1", "2"));