Skip to content

fix(validation): tighten ontology prefix IRI checks - #768

Open
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:fix/ontology-prefix-iri-validation-followup
Open

jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:fix/ontology-prefix-iri-validation-followup

Conversation

@jbonofre

Copy link
Copy Markdown
Member

Follow-up to #755, tightening has_absolute_iri_syntax() without adding third-party dependencies.

Changes

  • Reject malformed authorities, bare schemes, control characters, surrogates, and RFC 3987 disallowed delimiters in has_absolute_iri_syntax() (validation/validate.py):
    • Reject control characters (< 0x20, 0x7F–0x9F), lone surrogates (0xD800–0xDFFF), whitespace, and RFC 3987 disallowed ASCII delimiters (< > " { } | \ ^ \``) before urlsplit()` (which strips ASCII control whitespace).
    • Validate URL structure via stdlib urllib.parse.urlsplit and parts.port (catching invalid IPv6 literals and non-numeric/out-of-range ports).
    • Require a non-empty hostname whenever netloc is present (rejecting e.g. https://user@/ns# and https://:8080/ns#), and require a non-empty netloc or path (rejecting bare schemes like http:, https://, and https://#frag).
  • Update validate_ontology() docstring in validation/validate.py to document prefix IRI validation alongside the other ontology checks.
  • Expand tests in validation/tests/test_validate.py:
    • Cover IPv6 hosts, explicit ports, internationalized domain/path IRIs (\u-escaped), and file:// path IRIs as accepted values.
    • Cover newlines, NUL bytes, disallowed delimiters, lone surrogates, bare schemes, malformed IPv6 brackets, invalid ports, missing hosts, and non-string prefix values as rejected values.

Testing

  • uv run --no-project validation/test_validate.py: 59 tests passed.
  • uv run --no-project --with pytest --with pyyaml --with jsonschema --with sqlglot -m pytest validation/tests/: 775 passed, 1 skipped.
  • make validate spec-check: canonical examples and generated spec types passed.
  • git diff --check: passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant