enketo-core icon indicating copy to clipboard operation
enketo-core copied to clipboard

Single and double quotes in pulldata CSV function will cause XPath evaluator error

Open yixi8524 opened this issue 3 years ago • 1 comments

Describe the bug single and double quotes in pulldata CSV function will cause XPath evaluator error

To Reproduce Steps to reproduce the behavior. If applicable please include the smallest possible XLSForm or XForm (as zip or link).

  1. create an text question with concat('The street is ',pulldata('Intersections', 'Street1', 'IntersectionID', ${intersection_id})) calculation. pulldata-test.xlsx

  2. upload the CSV file.

IntersectionID Street1
1000 Spencer" St
2000 King' St
3000 William St
  1. Run the survey, select IntersectionID 1000 or 2000
  2. See error
"Could not evaluate: concat('The street is ', "Spencer" St"), message: The expression is not a legal expression."

Expected behavior

  • Pulldata CSV function can use in other function

Screenshots

image

yixi8524 avatar Jul 19 '21 06:07 yixi8524

This maybe because of the _replacePullDataFn in form-model. The pullDataResult will wrapper by double-quotes. when the pulldata result have single or double quotes will cause this error. https://github.com/enketo/enketo-core/blob/b83271e8cc88fb79ddeb4f79fb1194d2aac9f421/src/js/form-model.js#L1142-L1156

yixi8524 avatar Jul 19 '21 07:07 yixi8524