Forum Discussion
Using SCAN to validate an URI
I need to validate an URI. I'd like to use a policy but iRule works as well.
I need to check if an URI is between 2 and 8 characters long and that it contains only digits and upper or lower letters. The regex expression is something like this " ^[a-zA-Z0-9]{2,8} ", but how can I use scan to do the same thing.
If the validation fails then I want to reset the connection, if it is a valid URI then I want to send it to the pool.
How can I solve this problem?
Thanks in advance.
- Stanislas_Piro2
Cumulonimbus
- URI always starts with / so your regex expression may not work.
- scan command is not the best solution to define length filtering
You can use following code in you irule to check both length filtering and format:
set uri [string range [HTTP::uri] 2 end] if {([set length [string length $uri]] == 8 || $length == 2 ) && [string is alnum $uri ]} { #actions if true } else { #actions if false }
Recent Discussions
Related Content
* 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