IATI / js-validator-api

Pure JavaScript IATI validator implementation
GNU Affero General Public License v3.0
1 stars 1 forks source link

Validator API returns incorrect line counts for schema and ruleset violations if file uses old Mac-style `CR` only line endings #550

Open simon-20 opened 6 months ago

simon-20 commented 6 months ago

Brief Description Validator API will return incorrect line counts for schema and ruleset violations if file uses old Mac-style CR only line endings.

The Validator has to manually count lines for violation reporting because it splits up IATI XML activity files by activity, generating a new XML DOM object for each. The code which counts lines just counts LR characters; it is here:

https://github.com/IATI/js-validator-api/blob/769bcd55ff396c332644fd4f59189cdea9c5a627/services/rulesValidator.js#L953

This means line counts will be inaccurate if the file uses any single CR as line endings.

Severity Low

simon-20 commented 6 months ago

Although very few desktop/development systems use CR-only line endings, plenty of files in the IATI corpus have mixed line endings where at least some lines are CR. Such files are valid XML.

simon-20 commented 6 months ago

Problem also exists in getLineStart:

https://github.com/IATI/js-validator-api/blob/769bcd55ff396c332644fd4f59189cdea9c5a627/services/rulesValidator.js#L828