Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Percent encoding should be applied to params, not the whole string
Browse files Browse the repository at this point in the history
  • Loading branch information
ufna committed Sep 20, 2015
1 parent 1344c45 commit 759d4e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/VaRestPlugin/Private/Json/VaRestRequestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ FString UVaRestRequestJSON::PercentEncode(const FString& Text)
OutText = OutText.Replace(TEXT("\""), TEXT("%22"));
OutText = OutText.Replace(TEXT("#"), TEXT("%23"));
OutText = OutText.Replace(TEXT("$"), TEXT("%24"));
//OutText = OutText.Replace(TEXT("&"), TEXT("%26"));
OutText = OutText.Replace(TEXT("&"), TEXT("%26"));
OutText = OutText.Replace(TEXT("'"), TEXT("%27"));
OutText = OutText.Replace(TEXT("("), TEXT("%28"));
OutText = OutText.Replace(TEXT(")"), TEXT("%29"));
OutText = OutText.Replace(TEXT("*"), TEXT("%2A"));
OutText = OutText.Replace(TEXT("+"), TEXT("%2B"));
OutText = OutText.Replace(TEXT(","), TEXT("%2C"));
//OutText = OutText.Replace(TEXT("/"), TEXT("%2F"));
OutText = OutText.Replace(TEXT("/"), TEXT("%2F"));
OutText = OutText.Replace(TEXT(":"), TEXT("%3A"));
OutText = OutText.Replace(TEXT(";"), TEXT("%3B"));
OutText = OutText.Replace(TEXT("="), TEXT("%3D"));
//OutText = OutText.Replace(TEXT("?"), TEXT("%3F"));
OutText = OutText.Replace(TEXT("?"), TEXT("%3F"));
OutText = OutText.Replace(TEXT("@"), TEXT("%40"));
OutText = OutText.Replace(TEXT("["), TEXT("%5B"));
OutText = OutText.Replace(TEXT("]"), TEXT("%5D"));
Expand Down Expand Up @@ -224,14 +224,14 @@ void UVaRestRequestJSON::ProcessRequest(TSharedRef<IHttpRequest> HttpRequest)
if (!Key.IsEmpty() && !Value.IsEmpty())
{
UrlParams += ParamIdx == 0 ? "?" : "&";
UrlParams += Key + "=" + Value;
UrlParams += UVaRestRequestJSON::PercentEncode(Key) + "=" + UVaRestRequestJSON::PercentEncode(Value);
}

ParamIdx++;
}

// Apply params to the url
HttpRequest->SetURL(HttpRequest->GetURL() + UVaRestRequestJSON::PercentEncode(UrlParams));
HttpRequest->SetURL(HttpRequest->GetURL() + UrlParams);

break;
}
Expand Down

0 comments on commit 759d4e8

Please sign in to comment.