Skip to content

Eqs 766 add html validation#387

Merged
oms09 merged 35 commits into
mainfrom
eqs-766-add-html-validation
May 15, 2026
Merged

Eqs 766 add html validation#387
oms09 merged 35 commits into
mainfrom
eqs-766-add-html-validation

Conversation

@oms09
Copy link
Copy Markdown
Contributor

@oms09 oms09 commented Apr 15, 2026

Motivation and Context

After the investigation into validator gaps, HTML tags and entities was not being validated.

What has changed

  • Added validate_html() to iterate through all translatable schema text.
  • Implemented HTML tag validation using a stack-based approach.
  • Ensures only allowed tags are used (p, strong, a, b, br, img), validates correct opening/closing tag structure, handles self-closing tags (br, img)
  • Added validation for HTML entities Supports numeric (decimal and hexadecimal) and named entities, uses html.entities.html5 for validation
  • Detects whitespace before br tags
  • Ensures p tags appear at the start of a sentence (ignoring whitespace and wrapper characters)
  • unit tests added

How to test?

make test
run validator and runner then run make validate-test-schemas to ensure there are no errors
check code

Links

https://officefornationalstatistics.atlassian.net/browse/EQS-766
Rhys Validation PR - #244

Screenshots (if appropriate)

@oms09 oms09 marked this pull request as ready for review April 22, 2026 16:21
@oms09 oms09 requested a review from a team as a code owner April 22, 2026 16:21
Comment thread app/error_messages.py Outdated
Comment thread app/validators/questionnaire_validator.py
Comment thread app/validators/questionnaire_validator.py Outdated
Comment thread app/validators/questionnaire_validator.py Outdated
Comment thread app/validators/questionnaire_validator.py Outdated
Comment thread tests/schemas/invalid/test_invalid_html_tags.json Outdated
Comment thread app/validators/questionnaire_validator.py
@oms09 oms09 force-pushed the eqs-766-add-html-validation branch from dd9cb73 to d928bfa Compare May 15, 2026 14:11
@oms09 oms09 merged commit 7b0f105 into main May 15, 2026
9 checks passed
@oms09 oms09 deleted the eqs-766-add-html-validation branch May 15, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants