OpenClinica / enketo-oc

OpenClinica's fork of the Enketo web forms monorepo
Apache License 2.0
0 stars 5 forks source link

Substring containing < followed by an alphabetic character will not be displayed in the Query Widget history #27

Open eprager412 opened 1 year ago

eprager412 commented 1 year ago

Describe the bug Text "<letter" displays null instead of "<letter" when viewing query, annotation, or reason for change in the Query Widget.

To Reproduce ---Annotations & Query----

  1. Open attached form in mode /edit/fs/c/i/ simplequery.xform.txt
  2. Add a query or annotation to the "Date" question with the text string "<e".
  3. Review query within record
  4. Query will display as empty

If the text entered had been "some text <e", then the query display will be "some text". Everything starting with the first "<" is not displayed. The same occurs when reopening the form with an instance containing this query string. Note that the instance represents the "<" character as "<".

----Reason for Change----

  1. Open attached form in mode /edit/fs/c/i/
  2. Add todays date for question "Date".
  3. Submit record
  4. After submit change date from today to yesterday for question "Date"
  5. Add Reason for change "<e"
  6. Review audit log for item "Date" within the record
  7. Reason for change value will display as empty

Expected behavior Value displayed within record matches the value that the user entered for the query, annotation, or reason for change (including the "<" and characters after it.

Screenshots

2023-11-01_16-27-12 2023-11-01_16-34-13

Browser and OS (please complete the following information):

Other helpful info: There are no errors in the network tab when submitting or reviewing a query. The data entered for a query can be viewed in other areas of the system.

MartijnR commented 1 year ago
curl --user enketorules: -d \
"server_url=http://localhost:3000&form_id=language.test&ecid=a&lang=de&instance=\
<data xmlns:OpenClinica= \"http://openclinica.com/odm\" xmlns:enk= \"http://enketo.org/xforms\" xmlns:jr= \"http://openrosa.org/javarosa\" xmlns:oc= \"http://openclinica.org/xforms\" xmlns:orx= \"http://openrosa.org/xforms\" id= \"language.test\" version= \"1\">\
    <page1>\
        <locale_note />\
        <yn1 />\
        <locale_note_comment oc:queryParent= \"locale_note\" />\
        <yn1_comment oc:queryParent= \"yn1\">\
    {\"queries\":[{\"type\":\"comment\",\"id\":\"1\",\"date_time\":\"2023-01-18T11:34:36.608-05:00\",\"comment\":\"four %26lt%3Bfive -%26amp%3B%20%26gt%3B%20%26lt%3B\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"50b52cae-6c5b-4d1a-ab70-3e05b31e3784\"}]}</yn1_comment>\
    </page1>\
<meta>\
        <instanceID>uuid:e1623dbf-bf87-4b2a-8a5a-85ae832f31f3</instanceID>\
    </meta></data>\
&instance_id=123" http://localhost:8005/oc/api/v1/instance/edit

The challenge with reproducing was not realizing that we need to 'entity-encode' (for curl) the 'xml-encoded' content, so < becomes %26lt%3B.

MartijnR commented 1 year ago

@eprager412 @pbowen-oc Could you please post the content of the instance sent to Enketo (a response to a request to /submission), such as below?

Screenshot 2023-11-02 at 3 49 51 PM
pbowen-oc commented 1 year ago

@MartijnR - This is visible on the form without reopening it.

Enter new query text: Screenshot 2023-11-02 212154

After updating the query: Screenshot 2023-11-02 212227

The other query in that screenshot is coming from the instance: It was entered as "test1 <test0" query less than.instance.txt

pbowen-oc commented 1 year ago

@MartijnR - Sorry for the confusion. The endpoint was incorrect in the original description. This issue occurs with the standard new form or existing form field submission endpoints. I changed it above to reflect that it occurs in /edit/fs/c/i/.