Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The output of client does not escape values according to the target format #78

Closed
bcarlin opened this issue Aug 26, 2020 · 2 comments · Fixed by #67
Closed

The output of client does not escape values according to the target format #78

bcarlin opened this issue Aug 26, 2020 · 2 comments · Fixed by #67

Comments

@bcarlin
Copy link
Member

bcarlin commented Aug 26, 2020

Some output values can contain XML-like data.
When we ask the command to format the output in XML with -xml, this produce a valid XML structure, but it does not match the intent.

For example, with the output for a failed transfer, I have the following XML (the formatting has been added by me to highlight what I mean):

<xml>
  <command>DirectTransfer</command>
  <args>etc/conf.d/server2/client.xml -file world.txt -to server1 -rule error -xml </args>
  <status>2</status>
  <statusTxt>Transfer in status: FAILED with no Transfer Id</statusTxt>
  <remote>server1</remote>
  <error>
    ErrorPacket:(3:E) PreTask in error: Runner is failed: 
    <STATUS>-1</STATUS>
    <ERROR>will fail </ERROR>
  </error>
</xml>

Though it is valid, <STATUS> and <ERROR> are part of <error> and not tags of the main XML document.
The output should use entity refs to protect the content of the <error> message:

<xml>
  <command>DirectTransfer</command>
  <args>etc/conf.d/server2/client.xml -file world.txt -to server1 -rule error -xml </args>
  <status>2</status>
  <statusTxt>Transfer in status: FAILED with no Transfer Id</statusTxt>
  <remote>server1</remote>
  <error>
    ErrorPacket:(3:E) PreTask in error: Runner is failed: 
    &lt;STATUS&gt;-1&lt;/STATUS&gt;
    &lt;ERROR&gt;will fail &lt;/ERROR&gt;
  </error>
</xml>

edit:
I realised by reviewing #67 that the same problem exists for other output formats.

Here is an example with -csv. The culprits are the semicolon (;) between "will" and "fail" and the new line which are not protected, hence adding an extra column in the first line, and a second record in the second line:

command;args;status;statusTxt;remote;error
DirectTransfer;etc/conf.d/server2/client.xml -file world.txt -to server1 -rule error -csv ;2;Transfer in status: FAILED with no Transfer Id;server1;ErrorPacket:(3:E) PreTask in error: Runner is failed: <STATUS>-1</STATUS><ERROR>will ;fail
always

The output should be:

command;args;status;statusTxt;remote;error
DirectTransfer;etc/conf.d/server2/client.xml -file world.txt -to server1 -rule error -csv ;2;Transfer in status: FAILED with no Transfer Id;server1;"ErrorPacket:(3:E) PreTask in error: Runner is failed: <STATUS>-1</STATUS><ERROR>will ;fail
always"
@bcarlin bcarlin changed the title Parsing the output of client commands might fail for XML formatting The output of client does not escape values according to the target format Aug 26, 2020
@fredericBregier
Copy link
Collaborator

fredericBregier commented Aug 26, 2020

Proposal will be:

  • csv : replace all ';' by ';'
  • xml : replace all <, > by [, ] respectively

@fredericBregier
Copy link
Collaborator

fredericBregier commented Aug 26, 2020

See update of #67

@fredericBregier fredericBregier linked a pull request Aug 26, 2020 that will close this issue
fredericBregier added a commit to fredericBregier/Waarp-All that referenced this issue Aug 28, 2020
OutputFormat options were lost in last release. This fixes the issues waarp#60 and waarp#78.
fredericBregier added a commit that referenced this issue Aug 28, 2020
OutputFormat options were lost in last release. This fixes the issues #60 and #78.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants