maria-grigorieva / icatproject

Automatically exported from code.google.com/p/icatproject
0 stars 0 forks source link

export does not properly quote double quotes #154

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The export call of the ICAT RESTful interface does not always produce properly 
formatted output.  In particular, double quotes embedded in string values are 
not properly quoted.

Quote the doc on the file format: "All strings must be enclosed in double 
quotes and to represent a double quote within the string then two double quotes 
must be used."

What steps will reproduce the problem?
1. Create an investigation having double quotes in a string attribute:
>>> investigation = client.new("investigation")
>>> investigation.facility = facility
>>> investigation.type = type
>>> investigation.name = "Test"
>>> investigation.visitId = "1"
>>> investigation.title = 'A test investigation with "double quotes" in the 
title.'
>>> investigation.create()

2. Export the ICAT content using the export call of the ICAT RESTful interface. 
 The line representing the investigation in the output reads:

|Investigation(createId:0,createTime:1,modId:2,modTime:3,doi:4,endDate:5,facilit
y(name:6),name:7,releaseDate:8,startDate:9,summary:10,title:11,type(facility(nam
e:12),name:13),visitId:14)
|"useroffice",2015-04-13T14:50:42.000+02:00,"useroffice",2015-04-13T14:50:42.000
+02:00,NULL,NULL,"ESNF","Test",NULL,NULL,NULL,"A test investigation with 
"double quotes" in the title.","ESNF","Experiment","1"

Note the embedded double quotes in the output that are not represented by two 
double quotes as required by the format specification.

3. Consequently, trying to import the file back into ICAT fails with the error:
BAD_PARAMETER: Expected token from types [COMMA] at token double in , A test 
investigation with  < double > quotes  in the title.  at line 166

What is the expected output? What do you see instead?

Expected an output file that is properly formatted according to the spec.

Please use labels and text to provide additional information.

There are also other issues with embedded special characters in string values.  
For instance, export also doesn't seem to handle embedded newlines properly.  
But here, the format specification doesn't even say how an embedded newline 
should be properly represented.

Original issue reported on code.google.com by rolf.kr...@helmholtz-berlin.de on 13 Apr 2015 at 1:49

GoogleCodeExporter commented 9 years ago

Original comment by dr.s.m.f...@gmail.com on 6 May 2015 at 9:09