Skip to content

Commit

Permalink
http: url_decode: translate plus back into char
Browse files Browse the repository at this point in the history
As seen in scylladb/scylladb#12393,
the client may encode space characters into `+` in the url
query parameters (as well as to `%20`)

https://en.wikipedia.org/wiki/URL_encoding#The_application.2Fx-www-form-urlencoded_type
explains that:

> When data that has been entered into HTML forms is submitted,
> the form field names and values are encoded and sent to the
> server in an HTTP request message using method GET or POST,
> or, historically, via email. The encoding used by default is
> based on an early version of the general URI percent-encoding
> rules, with a number of modifications such as newline normalization
> and replacing spaces with + instead of %20.

and that is used for encoding is used by the Python requests library,
that is used by our scylla-api-client.
See https://github.com/scylladb/scylla-api-client/blob/485b25d95df0e8c56c1639a8a8be99b6c676e799/scylla_api_client/rest/__init__.py#L96

Refs scylladb/scylladb#12393
Fixes scylladb#1530

Signed-off-by: Benny Halevy <[email protected]>

Closes scylladb#1531
  • Loading branch information
bhalevy authored and nyh committed Mar 6, 2023
1 parent a90a467 commit 799a9aa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/http/url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ bool url_decode(const std::string_view& in, sstring& out) {
} else {
return false;
}
} else if (in[i] == '+') {
buff[pos++] = ' ';
} else {
buff[pos++] = in[i];
}
Expand Down

0 comments on commit 799a9aa

Please sign in to comment.