Forum Discussion
mikand_61525
Nimbostratus
Feb 17, 2012Replace (and remove) characters from URIs?
Im trying to setup an irule that will convert "\" into "/" and also remove redundant "/" (turning "//" into "/") for HTTP::uri.
What is the recommended way (performance wise) to do these two things in v10 and v11 nowadays?
I also wonder how I can efficiently search for a group of specific hexvalues?
I understand one can use:
if { [string match {*abc*} $uri] }
to search for "abc" withing a string but im not sure that the following will work:
if { [string match {\x00 || \x01} $uri }
or am I supposed to to make a large if-statement out of this or can datagroup list be used aswell?
3 Replies
- nitass
Employee
in case not using data group.
e.g.[root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set uri [HTTP::uri] set cvt_back_slash [string map {\\ /} $uri] set rm_double_slash [string map {// /} $cvt_back_slash] log local0. "$uri -> $rm_double_slash" } } [root@ve1023:Active] config cat /var/log/ltm Feb 17 03:30:43 local/tmm info tmm[4822]: Rule myrule : /test1\/test2/test3//test4 -> /test1/test2/test3/test4 - nitass
Employee
data group.
e.g.[root@ve1023:Active] config b class convert_list list class convert_list { { "//" { "/" } "\\\\" { "/" } } } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set uri [HTTP::uri] foreach item [class get convert_list] { set uri [string map $item $uri] } log local0. "[HTTP::uri] -> $uri" } } [root@ve1023:Active] config cat /var/log/ltm Feb 17 03:55:35 local/tmm info tmm[4822]: Rule myrule : /test1\/test2/test3//test4 -> /test1/test2/test3/test4 - mikand_61525
Nimbostratus
Thanks! :-)
Are there any drawbacks of using data group similar to use global variable vs local variable?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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