dpatty
September 9, 2022, 1:58pm
1
Hi ,
I have to check in condition if a response content starts with double quote . How ever proxy is not getting saved and getting below error .
AM-OK
(response.content |= "\"")
Error -
Error in target default. Invalid condition: (message.content |= “”") in policy AM-OK. Reason: Malformed expression: Unterminated "
Best Regards,
Patty
Try
<Condition>response.content |= "\u0022"</Condition>
dpatty
September 9, 2022, 3:47pm
3
Hi Dino ,
response content is “OK” . But this condition is evaluating to false .
<Condition>response.content |= "\u0022"</Condition>
Best Regards,
Patty
let me try it, and get back to you.
Hey Patty
Sorry for the delay. I experimented a little and I could never encode a double-quote inside the right-hand-side of a simple comparison Condition. Like |= or = or others.
But there is a regex match operator, which accepts the unicode escape for a double quote. This is what worked for me:
<Step>
<Name>AM-1</Name>
<Condition>response.content ~~ "(?s)\s*\u0022[A-Z]+\u0022\s*"</Condition>
</Step>
That ~~ is a JavaRegex matcher, in lieu of the simpler |= operator. I can explain its parts:
(?s) this is the DOTALL option, tells the regex to match dots and \s to newlines
\s* matches zero or more whitespace
\u0022 is the unicode escape code for a double-quote, ascii 34. It matches "
[A-Z]+ matches one or more uppercase ASCII characters between A and Z, inclusive.
\u0022 matches the trailing double quote
\s* matches trailing whiltespace, zero or more characters
You can construct a different regex that is simpler or more general, if you like. Maybe something like
<Condition>response.content ~~ "(?s)\s*\u0022.+"</Condition>
…which says “any string that starts with some optional whitespace followed by a double quote.”
In my tests, the (?s) is essential when matching against response.content, even if the response.content is a single line, or has no newlines. I don’t know why.
dpatty
September 23, 2022, 4:55am
7
Thank you Dino . Your solution worked .
However it worked when I compared the double quotes from property set . I implemented like this .
(message.content != null) and !(message.content =| propertyset.general.doublequote)
Best Regards,
Patty.