Encoding automatically in Postman - postman

i have an uri that ends in something like this
...headfields=id,id^name
i was using the encodeURIComponent(Right click on the uri) to replace that "^" by "%5E" and works fine.
But my question is, can this be automatic in postman?

url encoding is done automatically you don't have to explicitly do that
Note for query parameters if you type in special character with special meaning in the url then it will not encode it , if you give it in params then it will
usecase 1 : typing in special characters
usecase2 : giving it in params
you can also encode in prerequest script as :
pm.request.url=encodeURI(pm.variables.replaceIn(pm.request.url))

Related

WSO2 EI encodes special symbols like "/", "&" and etc. when transforms from property to part of uri

I have a sequence with string property that I added to end of uri string. If string has special symbols like '?','/' and etc, they encodes to uri encoded string and broke uri. For example:
api/res?param1=val1&param=val2
becomes
api/res?param1=val1%26param2%3Dval2
api/res?param1=val1 - main part of uri
&param=val2 = uri.var.param part from Parameter Mediator that I had add to uri by template like: uri-template="/api/res?param1=val1{uri.var.param}"
You may use legacy encoding for this purpose and it will just append without doing any change.
For example like follows
uri-template="/api/res?param1=val1{+uri.var.param}
Please note the + sign there.
Thanks

Wrong encoding when retrieving get argument

I have a an url encoded with URL encoding, namely : /filebrowser/?cd=bank/fran%E7ais/essais
The problem is that if I retrieve the argument through :
path = request.GET.get('relative_h', None)
I get :
/filebrowser/?cd=bank/fran�ais/essais
instead of:
/filebrowser/?cd=bank/français/essais
or :
/filebrowser/?cd=bank/fran%E7ais/essais
Yet, %E7 does correspond to 'ç', as you can see there.
And since the %E7 is decoded with the replacement character, I can't even use urllib.parse.unquote to get my 'ç' back...
Is there a way to get the raw argument or the correctly decoded string?
Switching the request encoding to latin-1 before accessing the parameter returned the correctly decoded string for me, when running your example locally.
request.encoding = 'latin-1'
path = request.GET.get('relative_h', None)
However, I'm not able to tell you why that would be, since I would have assumed that the default encoding of utf-8 would have handled that particular character.

Regex capture group in Varnish VCL

I have a URL in the form of:
http://some-site.com/api/v2/portal-name/some/webservice/call
The data I want to fetch needs
http://portal-name.com/webservices/v2/some/webservice/call
(Yes I can rewrite the application so it uses other URL's but we are testing varnish at the moment so for now it cannot be intrusive.)
But I'm having trouble getting the URL correctly in varnish VCL. The api part is replaced by an empty string, no worries but now the portal-name.
Things I've tried:
if (req.url ~ ".*/(.*)/") {
set req.http.portalhostname = re.group.0;
set req.http.portalhostname = $1;
}
From https://docs.fastly.com/guides/vcl/vcl-regular-expression-cheat-sheet and Extracting capturing group contents in Varnish regex
And yes, std is imported.
But this gives me either a
Syntax error at
('/etc/varnish/default.vcl' Line 36 Pos 35)
set req.http.portalhostname = $1;
or a
Symbol not found: 're.group.0' (expected type STRING_LIST):
So: how can I do this? When I have extracted the portalhostname I should be able to simply do a regsub to replace that value with an empty string and then prepend "webservices" and my URL is complete.
The varnish version i'm using: varnish-4.1.8 revision d266ac5c6
Sadly re.group seems to have been removed at some version. Similar functionality appears to be accessible via one of several vmods. See https://varnish-cache.org/vmods/

A sharp in URL parameter

If you can help me I will be very grateful.
My problem is i send a request via google chrome like that :
http://localhost:8080/Webservise/rest/getinfo?user=user1&pwd=rdd#en&sscc=009
and whene i test the url he return :
user = user1
pwd=rdd
sscc= null
Because the # is an special caracter
any proposition ?
Thanks a lot.
Yes # is a fragment identifier. To ensure its interpreted as part of a query string you must URL encode it (to %23) - You should be doing this as routine for all query string values.

how to prevent the extra slashes comin in the url of the browser

urls.py
url(r'^kebreading/$', 'KEBReading1',name="kebreading"),
url(r'^kebreading/(?P<param>\w*)/(?P<date>\w*)/(?P<year>\w*)/(?P<month>\w*)/$', kEBReading1',name="kebreading")
i have a view which i pass 5 parameters to it. and the same view is being called when i dont pass any parameter. but five slashes gets appended to the url in the browser even wen i don pass any parameters. how to prevent this happening???
You can use the regexp ? sign to create an optional group and use ?: so Django do not pass this group as an *arg parameter
Something like :
url(r'^kebreading/(?:(?P<param>\w*)/(?P<date>\w*)/(?P<year>\w*)/(?P<month>\w*)/)?$', kEBReading1',name="kebreading")
There is a similar question #2325433