Escaping double quotes - Prepared Statement in JMeter - jmeter

I am trying to execute a stored procedure in JMeter using JDBC Request Sampler. One of the parameters include XML that contains quotes
I am getting the following error:
Response message: java.io.IOException: Cannot have quote-char in plain field:[ <xmlns:r="]
The setup:
QueryType: Prepered Update Statement
SQL Query: {CALL SPINSERT(?, ?)}
Parameters Values: Y, <xmlns:r="">
Parameters Types: CHAR, VARCHAR
I suppose I need to escape the double quotes, any ideas, how this should be done properly?

It's actually as per documentation on JMeter website, but the problem appeared to be that you cannot have a white space after the last double quote.
The list must be enclosed in double-quotes if any of the values
contain a comma or double-quote, and any embedded double-quotes must
be doubled-up, for example: "Dbl-Quote: "" and Comma: ,"

Related

Shell/Bash - extra characters in string variable after assigning cli result

In one of my variables I store result (string) from aws cli command.
When echoing the value it is displayed in " " but injecting it as a parameter shows that extra characters (&#34) are added at the beginning and end of the string.
How to eliminate these? What do they represent?
Code and error log:
dms_arn=$(aws dms describe-replication-tasks --filter Name=replication-task-id,Values="$dms_name" `--query=ReplicationTasks[0].ReplicationTaskArn --region us-east-1)`
echo Stopping Task "$dms_arn"
build 02-Nov-2021 18:52:01 Stopping Task "arn:aws:dms:us-east-1:account:task:XYZ"
error 02-Nov-2021 18:52:02
error 02-Nov-2021 18:52:02 An error occurred (InvalidParameterValueException) when calling the StopReplicationTask operation: Invalid task ARN: "arn:aws:dms:us-east-1:account:task:XYZ"
&#34 is the html code for double quote ("). The double quotes are being converted to html code.
Try using the —output text option with your aws command (so you don’t get quotes). See the documentation about output format: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html
If necessary, you can remove wrapping double quotes using shell parameter expansion:
dms_arn=${dms_arn%\"}
dms_arn=${dms_arn#\"}
echo "$dms_arn"
# quotes are gone
&#34 is the HTML entity corresponding to the double quotation marks.
See: entity
To convert them check: Short way to escape HTML in Bash? and Bash script to convert from HTML entities to characters

How to insert text starting with double quotes in a column delimited with | in a import command in db2

Table contains 3 columns
ID -integer
Name-varchar
Description-varchar
A file with .FILE extension has data with delimiter as |
Eg: 12|Ramu|"Ramu" is an architect
Command I am using to load data to db2:
db2 "Load CLIENT FROM ABC.FILE of DEL MODIFIED BY coldel0x7x keepblanks REPLACE INTO tablename(ID,Name,Description) nonrecoverable"
Data is loaded as follows:
12 Ramu Ramu
but I want it as:
12 Ramu "Ramu" is an architect
Take a look at how the format of delimited ASCII files is defined. The double quote (") is an optional delimited for character data. You would need to escape it. I have not tested it, but I would assume that you double the quote as you would do in SQL:
|12|Ramu|"""Ramu"" is an architect"
Delimited files (CSV) are defined in RFC 4180. You need to either use quotes for the entire field or none at all. Only in fields beginning and ending with a quote, other quotes can be used. They need to be escaped as shown.
Use the nochardel modifier.
If you use '|' as a column delimiter, you must use 0x7C and not 0x7x:
MODIFIED BY coldel0x7C keepblanks nochardel

YAML syntax sed in Gitlab-CI

I've made a mistake in the file below, but I cannot see where my mistake is. I have this command in my .gitlab-ci.yml configuration file.
- sed "s/use_scm_version=True/use_scm_version={'write_to': '..\/version.txt', 'root': '..'},\/"setup.py
It seems that the ":" are interpreted as a semicolon even if I surround the entire sed between double quotes.
(<unknown>): did not find expected key while parsing a block mapping at line 109 column 11
Any ideas ?
Since your double quotes are not at the beginning of the scalar node, they don't have special meaning in YAML and the colon is seen as the normal value indicator (and both the key and value have an embedded double quote).
I recommend you quote the whole scalar:
- "sed s/use_scm_version=True/use_scm_version={'write_to': '..\/version.txt', 'root': '..'},\/setup.py"
And optionally add \" (backslash escaped double quotes) as necessary within there if that doesn't work.

Phoenix -> csv -> invalid char between encapsulated token and delimiter

I need to upload a CSV dump file to the Phoenix database
Files that did not contain any special characters were loaded without problems
./psql.py -t TTT localhost /home/isaev/output.csv -d';'
But as soon as I tried to load the same file in which the data fields were met with quotes, I get an error
java.lang.RuntimeException: java.io.IOException: (line 1) invalid char between encapsulated token and delimiter
at org.apache.commons.csv.CSVParser$1.getNextRecord(CSVParser.java:398)
at org.apache.commons.csv.CSVParser$1.hasNext(CSVParser.java:407)
at org.apache.phoenix.util.UpsertExecutor.execute(UpsertExecutor.java:132)
at org.apache.phoenix.util.CSVCommonsLoader.upsert(CSVCommonsLoader.java:217)
at org.apache.phoenix.util.CSVCommonsLoader.upsert(CSVCommonsLoader.java:182)
at org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:308)
Caused by: java.io.IOException: (line 1) invalid char between encapsulated token and delimiter
at org.apache.commons.csv.Lexer.parseEncapsulatedToken(Lexer.java:275)
at org.apache.commons.csv.Lexer.nextToken(Lexer.java:152)
at org.apache.commons.csv.CSVParser.nextRecord(CSVParser.java:450)
at org.apache.commons.csv.CSVParser$1.getNextRecord(CSVParser.java:395)
... 5 more
For example on the first line (line 1) I have this entry
5863355029;007320071; ZAO "With a smile for life";True;
I found the solution myself:
-q'\'
Can someone come in handy
You can resolve your problem using quotes 2 times:
5863355029;007320071; ZAO ""With a smile for life"";True;
Each field may or may not be enclosed in double quotes. If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.
Check this link if you are interested in why: https://www.marklogic.com/blog/delimited_text_mlcp/

String replace function issue

I used string replace function in jmeter script and was working fine when I ran the script on the local machine but when the same script was run on the server, it is showing an error.
The function used is : ${__strReplace(${C_Create_Escape},",\\\",)}
where create escape is a regular expression.
On server showing 400 error not passing the string replace function.
Error:
"timestamp":1547805846520,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read document: Unexpected character ('\\' (code 92)): was expecting double-quote to start field name\n
at [Source: java.io.PushbackInputStream#463eb3f3; line: 1, column: 2804] (through reference chain:
com.acn.hps.gpp.gibs.dto.FormRequestDTO[\"gibsFormDTO\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('\\' (code 92)): was expecting double-quote to start field name\n at [Source: java.io.PushbackInputStream#463eb3f3; line: 1, column: 2804] (through reference chain: com.acn.hps.gpp.gibs.dto.FormRequestDTO[\"gibsFormDTO\"])","path":"/form/createOrEditForm"}
According to JMeter Documentation:
If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter.
This restriction has a side-effect: if you need to pass a backslash - you need to escape it with another backslash
So basically if you pass "a" to your function you will get \"a\" as the result:
While your server expects it to be escaped with the double slash, to wit \\"a\\"
My assumption is that you will need to add some more backslashes in order to be compliant with both JMeter Functions syntax and whatever your server expects. The resulting syntax would be:
${__strReplace(${C_Create_Escape},",\\\\\\\",)}
Check out Apache JMeter Functions - An Introduction article for more information on JMeter Functions concept.

Resources