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. ...
Jun 08, 2007
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
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
