Fixes/html entities in version#1693
Merged
sadiqkhoja merged 3 commits intogetodk:masterfrom Dec 8, 2025
Merged
Conversation
aab3983 to
d9d27bf
Compare
2 tasks
… _versionSplicer
d9d27bf to
fc570d1
Compare
sadiqkhoja
commented
Dec 5, 2025
Comment on lines
-545
to
+549
| // okay, we have found the thing we are looking for. | ||
| // idx points at the position of the closing " | ||
| // | ||
| // TODO: we cheat here and reference the hp2 internal tokenizer index to find | ||
| // out where the attribute actually is. the parser startIndex and endIndex point | ||
| // at the whitespace preceding the tag until the tag is closed. obviously this is | ||
| // pretty bad but i don't see a more robust solution right now. | ||
| const idx = parser.tokenizer.index; | ||
| const result = replace | ||
| ? `${xml.slice(0, parser.startIndex)}version="${insert}"${xml.slice(parser.endIndex)}` | ||
| : `${xml.slice(0, parser.endIndex-1)}${insert}"${xml.slice(parser.endIndex)}`; | ||
| parser.reset(); | ||
| return replace | ||
| ? pass(`${xml.slice(0, idx - value.length)}${insert}${xml.slice(idx)}`) | ||
| : pass(`${xml.slice(0, idx)}${insert}${xml.slice(idx)}`); | ||
| return pass(result); |
Contributor
Author
There was a problem hiding this comment.
latest version has fixed the bug around startIndex and endIndex, so we can use that.
alxndrsn
reviewed
Dec 5, 2025
lib/data/schema.js
Outdated
| const idx = parser.tokenizer.index; | ||
| const result = replace | ||
| ? `${xml.slice(0, parser.startIndex)}version="${insert}"${xml.slice(parser.endIndex)}` | ||
| : `${xml.slice(0, parser.endIndex-1)}${insert}"${xml.slice(parser.endIndex)}`; |
Contributor
There was a problem hiding this comment.
There's a subtle change here for the replace case. I think it introduces a bug in untested code paths.
Fix:
Suggested change
| : `${xml.slice(0, parser.endIndex-1)}${insert}"${xml.slice(parser.endIndex)}`; | |
| : `${xml.slice(0, parser.endIndex)}${insert}${xml.slice(parser.endIndex)}`; |
alxndrsn
requested changes
Dec 5, 2025
Contributor
alxndrsn
left a comment
There was a problem hiding this comment.
It looks like this aims to fix two separate bugs.
- The fix in
lib/model/frames/form.jsis tested intest/integration/api/forms/forms.js, and looks good, and I could approve immediately if submitted separately. - The fix in
lib/data/schema.jsis tested intest/unit/data/schema.js, and looks like it introduces a surprising bug in an untested code path. I think my suggestion will fix that.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes getodk/central#1470
See the analysis of the issue at getodk/central#1470 (comment)
What has been done to verify that this works as intended?
Added couple of tests.
Why is this the best possible solution? Were any other approaches considered?
The bug about
startIndexandendIndexin htmlparser2 mentioned in the previous comment has been fixed in the latest version so I thought it would be good to upgrade it and usestartIndexandendIndexto replace/append version value.We were using quite an old version of htmlparser2 i.e. v3.9 and the current version is v10.0. In one of our meeting we talked about using the latest versions of all dependencies where possible.
The upgrade is done in a separate PR to keep the changes for the actual bug fix minimum: #1692
To review this PR just see the latest commit.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
No
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
No
Before submitting this PR, please make sure you have:
make testand confirmed all checks still pass OR confirm CircleCI build passes