Forum Discussion
karamelo25_9966
Nimbostratus
Sep 08, 2009Converts any special characters to hex encoding
Hi,
I need to covert any special characters to hex encoding to implement a irule (it should be equivalent to "Escape" Internal RewriteMap Function in Apache mod_rewrite).
Thanks
8 Replies
- The_Bhattman
Nimbostratus
There is a command that can change string to hex
binary scan $string h* pkt_in_hex
log local0. "String in hex is: $pkt_in_hex" - karamelo25_9966
Nimbostratus
But I need to convert only special characters of a string to hex encoding. Do you know how I could do it? Thanks - The_Bhattman
Nimbostratus
I am not sure where I follow? Do you need to convert them in general or do you need to convert them problematically in an iRule? - karamelo25_9966
Nimbostratus
I have to make a irule where the value of a query parameter can contain some special character and it is necessary to convert these characters into hex. - The_Bhattman
Nimbostratus
Can you post and example of the full string with the querry. Also when it's converted where are you planning to use it?
CB - karamelo25_9966
Nimbostratus
I have to translate the following rewrite (apache) to irule:
RewriteMap escape int:escape
RewriteRule ^vegetables/(.*) vegetables.php?$1&HTTP_USER_AGENT=${escape:%{HTTP:User-Agent}}
The problem is that I don't know how translate the escape function. - hoolio
Cirrostratus
I'd guess that's doing URL encoding--not base64 encoding. You could use [URI::encode [HTTP::header User-Agent]] to URL encode the User-Agent header value.
Aaron - hoolio
Cirrostratus
All of the references I could find online for the Apache mod_rewrite escape functionality indicates they use URL (aka percent) encoding. The regex there doesn't quite make sense though as it's only going to match a URI starting with vegetables. A relative URI must start with a forward slash and an absolute URI must start with the protocol.
As CB suggests, can you provide some sample requests and the rewritten result?
Aaron
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