Skip to content

Commit

Permalink
URL-encode landing page params
Browse files Browse the repository at this point in the history
This was probably fine before because our base64'd JSON didn't need any characters that required URL-encoding, but we should future-proof it.
  • Loading branch information
adam-p committed Aug 19, 2019
1 parent f6a2346 commit 333294f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions psicash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Result<string> PsiCash::ModifyLandingPage(const string& url_string) const {
}

// Base64-encode the JSON
auto b64 = base64::TrimPadding(base64::B64Encode(json_data));
auto encoded_json = URL::Encode(base64::TrimPadding(base64::B64Encode(json_data)), false);

// Our preference is to put the our data into the URL's fragment/hash/anchor,
// because we'd prefer the data not be sent to the server.
Expand All @@ -321,12 +321,12 @@ Result<string> PsiCash::ModifyLandingPage(const string& url_string) const {
// When setting in the fragment, we use "#!psicash=etc". The ! prevents the
// fragment from accidentally functioning as a jump-to anchor on a landing page
// (where we don't control element IDs, etc.).
url.fragment_ = "!"s + kLandingPageParamKey + "=" + b64;
url.fragment_ = "!"s + kLandingPageParamKey + "=" + encoded_json;
} else {
if (!url.query_.empty()) {
url.query_ += "&";
}
url.query_ += kLandingPageParamKey + "="s + b64;
url.query_ += kLandingPageParamKey + "="s + encoded_json;
}

return url.ToString();
Expand Down

0 comments on commit 333294f

Please sign in to comment.