If I encode a string like this:
var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
it doesn't escape the slashes
I've searched and found this Objective C code:
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)unencodedString, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#", kCFStringEncodingUTF8 );
Is there an easier way to encode an URL and if not, how do I write this in Swift?
If I do this in .Net Core 3.1:
await new HttpClient().GetAsync("http://test.com/page?parameter=%2D%2E%5F%2E%2D");
then this happens:
GET http://test.com/page?parameter=-._.- HTTP/1.1
but this is what I want:
GET http://test.com/page?parameter=%2D%2E%5F%2E%2D HTTP/1.1
The background is that I get a signed Url from a third party and I need to use the url as it is, non-unescaped. I manage to find the resource with the unescaped url, but the signature check fails on the other end because the url they see in the request is not the url that was signed.
I can paste the url into any browser and get the resource, but the signature check fails when I do it programatically in .Net Core 3.1.
The unescaping is supposed to happen according to documentation on the Uri Class:
Escaped characters (also known as percent-encoded octets) that don't have a reserved purpose are decoded (also known as being unescaped). These unreserved characters include uppercase and lowercase letters (%41-%5A and %61-%7A), decimal digits (%30-%39), hyphen (%2D), period (%2E), underscore (%5F), and tilde (%7E).
I have tried solutions listed in these questions:
GETting a URL with an url-encoded slash. But the
schemeSetting seems not to work for .Net Core 3.1 and and neither does the workaround
How to make System.Uri not to unescape %2f (slash) in path?. Again
schemeSetting seems not to work for .Net Core 3.1, and neither does the workaround
So, does anyone know how I can use the signed url as is, non-unescaped, on .Net Core 3.1?
I tried EncodingJS and the built-in urlencode() function but it both returns the UTF-8 encoded one.
Would any one tell me how to get the SJIS-encoded letters properly in GAS? Thank you.
here's the problem:
my URL always replace
%2F. Is there a way to manipulate via
.htaccess that the URL don't replace the character
I tried it already with
AllowEncodedSlashes in the VirtualHost but that doesn't work either. I only ever get a 404 error.
Name = Trent, Bolt
I have encoded and assigned '%20' instead of "+" .Now it is Trent%2C%20Bolt . But it is not working.
Flow : (Trent, Bolt) -> (Trent%2C%2BBolt) -> (Replacing "%2B" to "%20") -> (Trent%2C%20Bolt).
May I get some help. Please!