Forum Discussion
mikand_61525
Feb 17, 2012Nimbostratus
Replace (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?
- nitassEmployeein case not using data group.
[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
- nitassEmployeedata group.
[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_61525NimbostratusThanks! :-)
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