Forum Discussion

EastCoast_16835's avatar
EastCoast_16835
Icon for Altostratus rankAltostratus
Dec 03, 2015

Rewriting response with STREAM not working properly

Hello,

 

I am developping an iRule to rewrite a response from the Web server.

 

I need to rewrite a chain of characters AND its length specified in the first character as a hex value.

 

The iRule works well except the part that rewrites the hexadecimal value of the length.

 

Code
STREAM::disable
STREAM::expression {@\x3Chttp://something1@\x17http://something2@}
STREAM::enable 

Where 

\x3C is the length of the original string
\x17 is the length of the replacement string

As a result, \x3C is interpreted correctly as an hex caracter ('<' ascii) but \x17 is interpreted as a string of characters.

 

So I am getting this byte sequence:

 

5C 78 31 37 68 74 74 70 3A 2F 2F ... -> \x17http:// ...

 

Instead of expected one:

 

17 68 74 74 70 3A 2F 2F ... -> .http:// ...

 

Is it a bug in the STREAM instruction or I am doing something wrong?

 

Thank you

 

  • This definitely looks like a bug in STREAM. If the code is modified as follows everything works well. Code set a \x3Chttp://something1 set b \x17http://something2 STREAM::disable STREAM::expression @$a@$b@ STREAM::enable
  • Hi,

    I can't say it is a bug, but it seems that the curly braces doesn't have the same behavior on the replacement string as to hex codes in the search string. Thereby, it should work by removing curly braces because this prevents command execution and variable expansion.

    e.g.

    it should work:    
    @\x3Chttp@\x17http@
    @$search@$replace@
    
    it shouldn't work:    
    {@\x3Chttp@\x17http@}
    {@$search@$replace@}