martin_58353
Sep 11, 2017Cirrus
Solved
STREAM::expression with special characters
I need inject code into JavaScript returned from server some code:
original code from server:
this.initNewTransfer(t, n),
replaced/injected code:
this.initNewTransfer(t, n),
INJECTED-CODE,
iRule definition (with not correct $find and $replace variables):
when HTTP_REQUEST {
set path [HTTP::path]
switch -glob $path {
"/some-java-script.js" {
HTTP::header remove "Accept-Encoding"
}
}
}
when HTTP_RESPONSE {
switch -glob $path {
"/some-java-script.js" {
find string: "this.initNewTransfer(t, n),"
set find "initNewTransfer\\(t, n\\),"
replace string: "this.initNewTransfer(t, n), INJECTED-CODE,"
set replace "initNewTransfer\\(t, n\\), INJECTED-CODE,"
STREAM::disable
STREAM::expression "@$find@$replace@"
STREAM::enable
}
}
}
The problem is with brackets in
\(
Can you please help me with this replacement? How can I match opening bracket in STREAM::expression?
I found correct strings for replacement:
set find "initNewTransfer\\x28t, n\\)" set replace "this.initNewTransfer\x28t, n\), INJECTED-CODE"
Is there any better solution?