Forum Discussion
Octavio_Rocha_6
Nimbostratus
Jun 08, 2007Remove HTML comments
Hi,
I'm new to irules and I need to remove any html comments present on the website html code.
Basically, I need to remove any line like this " " from the http response payload.
Any ideas?
thanks,
Octavio
5 Replies
- In case you hadn't gotten to it yet, here's a bit of code that should get you rolling:
when HTTP_REQUEST { Don't allow data to be chunked if { [HTTP::version] eq "1.1" } { if { [HTTP::header is_keepalive] } { HTTP::header replace "Connection" "Keep-Alive" } HTTP::version "1.0" } } when HTTP_RESPONSE { if { [HTTP::header exists "Content-Length"] } { set content_length [HTTP::header "Content-Length"] } else { set content_length 1000000 } if { $content_length > 0 } { HTTP::collect $content_length } } when HTTP_RESPONSE_DATA { Find the HTML comments set indices [regexp -all -inline -indices {} [HTTP::payload]] Replace the comments with spaces in the response log local0. "Indices: $indices" foreach idx $indices { set start [lindex $idx 0] set len [expr {[lindex $idx 1] - $start + 1}] log local0. "Start: $start, Len: $len" HTTP::payload replace $start $len [string repeat " " $len] } }
I modified the SSN scrubber on CodeShare. If anyone sees any problems with the HTML Comment regex, please let me know!
-Joe - hoolio
Cirrostratus
Per the w3 note (Click here), you can't have white space between the
Something like this comes close to matching the w3 definition of a comment: - Octavio_Rocha_6
Nimbostratus
Joe and Aaron,
It is working fine.
Thank you very much!
Octavio Posted By hoolio on 06/11/2007 3:36 AM
Per the w3 note (Click here), you can't have white space between the
Something like this comes close to matching the w3 definition of a comment:- hoolio
Cirrostratus
Cool. It doesn't get some odd ball cases like , but I think it should work for most situations.
Aaron
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
