https://bz.apache.org/bugzilla/show_bug.cgi?id=65205

            Bug ID: 65205
           Summary: Question mark needs to be escaped multiple times in
                    JSR223 Processors
           Product: JMeter
           Version: 5.4.1
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: JMETER_5.5

I suspect there's an issue with the special- and escape characters evaluation
in JSR233 processors, it is present in both 5.4.1, 5.2.1 and 5.1.1 versions,
and it probably goes back to earlier versions too.

Test environment: Win10 /w Java(TM) SE Runtime Environment (build
1.8.0_261-b12)

Issue/steps to repro:
I have a JSR233 PreProcessor that runs a small Groovy script, which basically
chops an URL into smaller chunks and stores them in their jmeter variables.
When I try to split a string with a question mark delimiter, I get a
"java.util.regex.PatternSyntaxException: Dangling meta character" exception:

def tmp = s.split('?')  // java.util.regex.PatternSyntaxException: Dangling
meta character '? 

No problem, it needs to be escaped, like this:

def tmp = s.split('\\?')

The version above is a valid groovy code, it compiles and runs in the JDoodle
online tester (or any other JDK for that matter) -however-, running the test in
jmeter gives this error:

2021-03-26 17:28:08,933 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
script, Parse user input
javax.script.ScriptException:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script302.groovy: 13: Unexpected input: '(' @ line 13, column 23.
   def tmp = s.split('\?')
                         ^

Looks like the second backslash disappeared, suggesting there's some kind of
double (un)escaping going in the background. So the solution is to
double-double escape the meta-character, the modified line below both compiles
and runs in jmeter:

def tmp = s.split('\\\\?')

I'm not sure if this is intentional, but sweeping trough the documentation and
browsing trough countless S:O threads and tutorials yield no evidence about
this. It is a pretty confusing behavior, to say the least.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to