Forum Discussion

jwlarger's avatar
jwlarger
Icon for Cirrus rankCirrus
Nov 06, 2019

iRule to replace { - } with %7B - %7D

I need to parse incoming headers and selectively replace { or } with %7B or %7D.

(v11.6.3)

 

Something like ?

when HTTP_REQUEST {

  if { [HTTP::uri] starts_with "/someuri/" } {

    HTTP::uri [string map {"/{/" "/%7B/"} [HTTP::uri]]

  }

}

 

But I suspect I'm not escaping the { character correctly.

01070151:3: Rule [/Common/test] error: /Common/test:3: error: [parse error: missing close-bracket][[string map {"/{/" "/%7B/"} [HTTP::uri]]

}]

 

TIA

  • Hi,

    You must escape this with back slash.

    HTTP::uri [string map {\{ %7B \} %7D} [HTTP::uri]]
     
    OR
     
    HTTP::uri [string map {\x7B %7B \x7D %7D} [HTTP::uri]]

    I hope it helps.

    Regards.

  • Hi,

    You must escape this with back slash.

    HTTP::uri [string map {\{ %7B \} %7D} [HTTP::uri]]
     
    OR
     
    HTTP::uri [string map {\x7B %7B \x7D %7D} [HTTP::uri]]

    I hope it helps.

    Regards.