Forum Discussion

Yannick_385905's avatar
Yannick_385905
Icon for Nimbostratus rankNimbostratus
Mar 22, 2019

Backslash in STREAM::expression

Hello,

I have some trouble to replace every occurence that match something like 'http:\/\/site.sub.domain.com' by 'https:\/\/site.domain.com'.

My irule looks like the following :

when HTTP_RESPONSE {
  if { [HTTP::header value Content-Type] contains "text" } {
    STREAM::disable
    STREAM::expression [list "@http:\\/\\/site.sub.domain.com@https:\\/\\/site.domain.com@" "@http://site.sub.domain.com@https://site.domain.com@"]
    STREAM::enable
  }
}

This give me an error : TCL error: /Common/rewrite_site - Illegal argument (line 3) invoked from within "STREAM::expression [list "@http:\/\/site.sub.domain.com@https:\/\/site.domain.com@" "@;]"

So, I do some test :

STREAM::expression "@http:\\/\\/site.sub.domain.com@https:\\/\\/site.domain.com@"

-> Do not match

STREAM::expression "@http:././site.sub.domain.com@https:\\/\\/site.domain.com@"

-> OK -> replace 'http:\/\/site.sub.domain.com' by 'https:\/\/site.domain.com'

STREAM::expression [list "@http:././site.sub.domain.com@https:\\/\\/site.domain.com@" "@http://site.sub.domain.com@https://site.domain.com@"]

-> same error as above

From these tests, my first problem is that I don't know how to match a '\' but can work arround with '.' and my second problem is that it seems that when I try to use the '\' in a list, it generate an error.

Can someone show me the right way to do that ?

Thanks

  • Resolved, it work with this syntaxe :

    STREAM::expression {@http:\\/\\/site.sub.domain.com@https:\/\/site.domain.com@ @http://site.sub.domain.com@https://site.domain.com@}