Forum Discussion

Nik's avatar
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="" /]




[a href=" width="123" height="456" /]




[a href= /]




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 {@}




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







3 Replies

  • I think this might work, if you only want to rewrite a href's:

    when HTTP_REQUEST {
        Disable the stream filter for all requests
    when HTTP_RESPONSE {  
        Check if response type is text  
       if {[HTTP::header value Content-Type] contains "text"}{  
           Match a tags for
          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.
  • 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

    STREAM::expression {@<[^>]*?}