Coldfusion - Setting/Using URL Parameters - url

In ColdFusion, I understand how to work with URLs using the query string functions: i.e., the second parameter in:
test.cfm?par1=val1&par2=val2&par3=val3
can be accessed by:
<cfset Param2 = ListGetAt(CGI.QUERY_STRING,2,"&")>
However, I was tasked with making dynamic URLs with the parameters separated simply by slashes, i.e.:
test.cfm/val1/val2/val3
How can I construct a URL this way, and then utilize those parameters in the webpage it links to?
Edit: I understand it would be quite easy to construct a string that is "test.cfm/#val1#/#val2#/#val#" and use it as my URL; I was wondering if there was a cleaner, built-in way for CF to help me do it. I am still lost on how to access those in the page.

Param2 = listChangeDelims(CGI.QUERY_STRING,"/","&");
That will turn "foo=bar&sna=fu" into "foo=bar/sna=fu".
Or listChangeDelims(CGI.QUERY_STRING,"/","&=");
will change it to "foo/bar/sna/fu"

Related

Jmeter: Dynamic URL encrypted

I'm working on a test plan with Jmeter.
The issue is that I can't retrieve the URL link as he is managed dynamically.
The URL has the following format:
localhost\blablabla?PATHPARAM=qzflh%2FGJHBGDCV%GROPJHVFFFDDFGGCFD%JJYTGVFRTVFGGFF%JUYGBG
I already try to search the value of PATHPARAM in the previous requests to retrieve it using regular expression extractor but I didn't find it.
It seems that this url is generated inside a javascript code but the way to extract it is unknown for me, inside the js code I find the value : var url = actionName + "?" + params ;
Is that any way to catch the content or the var url in Jmeter, else have you any other solution to solve this issue with this dynamic URL.
Many thanks in advance for your help.
I can see 2 possible options:
If you are being redirected to this URL automatically (you might need to play with Redirect Automatically and Follow Redirects boxes in the HTTP Request sampler
If this is the case - you should be able to get it using the following Regular Expression Extractor configuration
If you need to replicate the logic of this param variable calculation - you can attempt to do it using JSR223 PreProcessor which can execute arbitrary JavaScript code

safe character to separate multiple urls

I am preparing a special string, in which keys are values are concatenated like below:
username=foo&age=24&email=foo#bar.com&homepage=http://foo.com
& is the separator for two key=value pairs
value is url encoded
I have a scenario where there are multiple home pages for a user.
I want to specify multiple urls for the homepage key
name=foo&age=24&email=foo#bar.com&homepage=url1<some_safe_url_separator_char>url2<some_safe_url_separator_char>url3
We have no control/idea over what url1, url2, .. may contain?
What is a good choice of some_safe_url_separator_char?
In other words I am not looking for a safe character to be used IN a url, but a safe character to be used to SEPARATE two urls in a string
well you can use URL re-writing for this .
It will make a URL that will be safe as it will hide the name of parameters
For refrence you can use URL rewriting
URL rewriting will make a url seprated by '/' and its tough to be decoded by an external person.
you can follow links i'm posting
URL rewriting for beginners

URL Encode string for Href ASP.NET MVC / Razor

I'm trying to build an Href using Razor
The string is going to end up looking like this:
https://www.notmysite/controller/action?order_ID=xxxxxxx&hashComparator=iFxp3%2BszAMaEB%2FnHCtRr9Ulhv0DumtyDumCik4gKypJqi0BdOGXXsr9QDkfefAsLaR1Xy%2BrX9VcuzP1pF2k6dL%2F92UxphzTKqNAZP2SSZGWtvyO5az%2F9JvDY%2Bsq5TBQo7%2FYAAMIU4QxiSX1SBKk8SUNECW3ZmKM%3D
In my model I have the order id and the hash string
As the route is not a part of my site I don't believe I can use the default methods like #Url.Action
and therefore can't use protocol: Request.Url.Scheme
like I've used elsewhere.
So at present I'm trying to figure out how to create this using string functions
I've tried
Url.Encode
Url.EscapeDataString
Html.Encode
but am getting no where fast:
Click Here to be transferred
The output text always has plusses and equals in them and doesn't work.
Which combination do I need?!
I've figured out a way of doing it:
#{
var url = string.Format(
"https://www.notmysite.co.uk/controller/action?order_ID={0}&hashComparator={1}",
#Uri.EscapeDataString(Model.bookingNumber.ToString()),
#Uri.EscapeDataString(Model.hashCode));
}
<p>Click Here to be transferred</p>
Edit 2015 - As mentioned by Jerads post - The solution is to only encode the query string elements and not the whole URL - which is what the above does.
This was the first link that came up for this issue for me. The answers didn't work for me though because I am using core, I think. So wanted to add this in.
System.Net.WebUtility.UrlEncode(MyVariableName)
If Url.Encode doesn't work try the above. Also as stated before don't use this on the entire URL string, just use it for the individual querystring variables. Otherwise there is a good chance your URL wont work.
The problem is that you're trying to encode the whole URL. The only pieces you want to encode are the querystring values, and you can just use Url.Encode() for this.
You don't want to encode the address, the querystring params, or the ? and & delimiters, otherwise you'll end up with an address the browser can't parse.
Ultimately, it would look something like this:
Click Here to be transferred
The easier method is to use #Html.Raw(Model.SomethingUrl)

What does "URL=" in a URL Mean?

May be a dumb question, but it's been bugging me recently. I see "URL=" inside alot of URL's, such as this one:
http://www.tierraantigua.com/search-2?url=http%3A%2F%2Flink.flexmls.com%2Fwws30ham
What exactly is this used to do? Is it part of the iFrame functionality? I know the last part of the URL (after the URL=) is the part being displayed in the iFrame, but I'm unsure of why it is included in the primary URL as well.
Thanks!
The url you see here is just a standard query parameter wit the name url and the encoded value http%3A%2F%2Flink.flexmls.com%2Fwws30ham which decodes to http://link.flexmls.com/Fwws30ham. Most of the times it is used for determining redirection or source information by the application you are using. It is entirely domain-specific and can have any meaning the website developer would like to use.
PHP GET
Description ΒΆ
An associative array of variables passed to the current script via the URL parameters.
$url = $_GET['url'];
echo $url; // http%3A%2F%2Flink.flexmls.com%2Fwws30ham

Allow plus sign in URL with MVC 3

I need to be able to allow the "+" sign for certain actions in a controller. I am building a tag filtering engine that allows something like this (ie. stackoverflow) : /Stuff/Tagged/tag-name-1+tag-name-2+other-tag
I know I can set allowDoubleEscaping="true" in the web.config, but it is not best practices for security reasons.
I am guessing there is a way using maybe a custom filer or some other registry in the global.asax?
StackOverflow is probably treating the + as a whitespace. Most likely they map the route /Stuff/Tagged/{*tags} and call string.split() on the tags. This actually works out great if you don't allow whitespace in your tags.
+ means whitespace in an url. You should URL encode them:
/Stuff/Tagged/tag-name-1%2Btag-name-2%2Bother-tag
You can use simple replace:
string url = Url.Action("Index", "YourController");
url = url.Replace("%2b", "+");

Resources