Forum Discussion
Chadri_103513
Nimbostratus
Jun 14, 2010set command broken by "//"
Hello,
I'm having an issue with one of my iRules and I wanted to see if anybody has run into this issue in the past. Basically, I have an iRule that inspects the URI for a set of commands and assigns a variable value in the process for further inspection. The issue that I have run into is that when a full URL is passed within the URI (referredby=http://www.abc.com for example), it breaks my iRule by not allowing the variable to be set. This appears to be specifically related to the "//" in the URI. Is there a way to force an iRule to ignore this string?
Here is the portion of the iRule that is breaking:
if { [HTTP::method] eq "GET"} {
set cmd [ URI::query [string tolower [HTTP::uri]] command ]
log local0. "Debug - command = '$cmd'"
When I look at the logs, I notice that if I issue the following command the iRule does not set the command:
http://testURL/interface.asp?command=createaccount&referredby=http://www.abc.com
Jun 14 15:32:09 tmm tmm[1717]: Rule test-80 HTTP_REQUEST : Debug - command = ''
But if I remove the "//", it works:
http://testURL/interface.asp?command=createaccount&referredby=http:www.abc.com
Jun 14 15:32:21 tmm tmm[1717]: Rule test-80 HTTP_REQUEST : Debug - command = 'createaccount'
Thanks in advance for your assistance.
Chris
- Chris_Miller
Altostratus
What does throwing quotes around that area do? - hoolio
Cirrostratus
Hi Chris,when RULE_INIT { set url {http:// testURL/interface.asp?command=createaccount&referredby=http: //www.abc.com} log local0. "\[URI::query $url command\]: [URI::query $url command]" set url {http:// testURL/interface.asp?command=createaccount&referredby=http://www.abc.com} log local0. "\[URI::query $url command\]: [URI::query $url command]" }
(I added spaces after each http:// instance to prevent the forums from autolinking the URLs)set url {http:// testURL/interface.asp?command=createaccount&referredby=http:// www.abc.com} set command [URI::query $url command] log local0. "\[URI::query $url command\]: $command" set url {http:// testURL/interface.asp?command=createaccount&referredby=http:www.abc.com} set command [URI::query $url command] log local0. "\[URI::query $url command\]: $command"
- Chadri_103513
Nimbostratus
Aaron, - Chris_Miller
Altostratus
Posted By Chadri on 06/15/2010 10:34 AM - hoolio
Cirrostratus
I don't think // has any special meaning in TCL or iRules though. - Chadri_103513
Nimbostratus
Chris, - Chadri_103513
Nimbostratus
Is there a way to simply search the URI for "//" and replace those characters with "" or something else? - L4L7_53191
Nimbostratus
Regarding your last question about the replacement of "//", as an example here's how I'd go after manipulating the query to remove the "//" from "http://".
Note: I've overly used variables for the sake of the example. You could very well simplify (and save cycles) to a single line like:when HTTP_REQUEST { set orig_query [HTTP::query] set new_query [string map {"http://" "http:"} $orig_query] log local0. "New query is $new_query" }
- Chadri_103513
Nimbostratus
Matt, - L4L7_53191
Nimbostratus
Great news, glad you're working. Once you're all stable and running well, let's revisit the rule to make those class calls CMP friendly (if that'll be of value to you - not sure what class of hardware you're on).
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects