getodk / getodk/web-forms

Normalize strings in XML and expression in a canonical form

Open
#175 1 comment 0 reactions 0 assignees View on GitHub
@odk/xpath
Dominant language
TypeScript
Stars
38
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Following test fails because unicode character in XML document is in decomposed form and in XPath expression is in precomposed form.

```
it.only('adhoc tests', () => {

// In the xml document, é is U+0065 (LATIN SMALL LETTER E) followed by U+0301 (COMBINING ACUTE ACCENT)
const testDocument = xml`é`;
const evaluator = new Evaluator({rootNode: testDocument});

// In the following expression, é is U+00E9 (LATIN SMALL LETTER E WITH ACUTE)
const actual = evaluator.evaluateBoolean(`/root/foo = 'é'`);

expect(actual).toBe(true);
})
```

From the XPath spec:

> NOTE: It is possible in Unicode for there to be two strings that should be treated as identical even though they consist of the distinct sequences of Unicode abstract characters. For example, some accented characters may be represented in either a precomposed or decomposed form. Therefore, XPath expressions may return unexpected results unless both the characters in the XPath expression and in the XML document have been normalized into a canonical form.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Evaluator and its evaluateBoolean entry point, using the XML template and XPath expression shown in the issue as the reproduction. Trace how strings from the XML document and expression are compared, then verify that the provided expectation evaluates to true after normalization.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, xml
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.