Allow for escaped quotes in webforms xpath
- Dominant language
- TypeScript
- Stars
- 38
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
If for any reason a form needs to escape quotes in a string the current xpath processing will fail.
Firstly the `tree-sitter-xpath` grammar will fail to parse the xpath. This is because string literals are defined as `_literal: () => choice(/"[^"]*"/, /'[^']*'/)` which doesn't check for any form of escaping so it isn't as greedy as it should be.
Secondly the xpath evaluator will need to be modified to unescape the strings at the right time.
There are multiple methods of escaping quotes in xpath so part of this issue will be to decide which to support. Some examples are: `\'`, `'''`, `'`.
This was first discovered while implementing the `pulldata` function ( #242 ) which fails in web-forms and Enketo if the resolved query string contains a single quote.
There's a [forum post](https://forum.getodk.org/t/different-behaviour-between-enketo-and-odk-collect-with-straight-quotes-in-select-from-file-questions/49973/3) outlining the issue in Enketo.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the pulldata case where a resolved XPath query contains a single quote, then inspect the tree-sitter-xpath string-literal grammar and the XPath evaluator. Decide which escaping forms to support, ensure supported expressions parse and are unescaped at evaluation time, and verify the web-forms behavior against the reported Enketo discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100