For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Nik's avatar
Nik
Icon for Cirrus rankCirrus
Jan 06, 2011

stream find/replace expression with an exclude - take 2

inserting base href code into a post breaks the whole page.. so here we go again with psudo html:

 

 

--

 

 

 

the problem is i'm breaking internet explorer compatibility with a find/replace that i'm doing. here's a more specific example. again, three different strings:

 

 

 

[base href="http://www.domain.com/" /]

 

 

 

[a href="http://www.domain.com/path/to/file.jpg width="123" height="456" /]

 

 

 

[a href=http://www.domain.com/file/without/quotes.html /]

 

 

 

now, if i do something like this, it replaces all three domain names with "/" however i only want to replace the second two, not the first since it breaks compatibility with internet explorer:

 

 

 

STREAM::expression {@http://forexforums.dailyfx.com/@/@}

 

 

 

using stream_matched might do the job, i was hoping there'd be something a little simpler though.

 

 

 

thanks.

 

 

3 Replies

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    I think this might work, if you only want to rewrite a href's:

    
    when HTTP_REQUEST {
        Disable the stream filter for all requests
       STREAM::disable
    }
    when HTTP_RESPONSE {  
    
        Check if response type is text  
       if {[HTTP::header value Content-Type] contains "text"}{  
    
           Match a tags for http://www.domain.com/
          STREAM::expression {@
  • it would be things like img and embed also, i just want to exclude base href.

     

     

    that does seem like a good solution though.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    You could make the regex more general and then check that STREAM::match in STREAM_MATCHED doesn't contain "< base href" before doing the replacement. This would match < followed by any number of chars that aren't a > followed by http://www.domain.com/:

    STREAM::expression {@<[^>]*?http://www.domain.com/@@}

    Aaron