Skip to content

Commit 0266ea2

Browse files
committed
file schema fixes
- expand uri validator tests - treat file as non-hierarchical
1 parent 2911a17 commit 0266ea2

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Changed
1010
- ci: Run workflows against 5.x.x branches ([#859](https://github.com/jsonrainbow/json-schema/pull/859))
11+
### Fixed
12+
- UriValidator: Allow `file:/` and `file:///` ([#856](https://github.com/jsonrainbow/json-schema/discussions/856))
1113

1214
## [6.6.3] - 2025-12-02
1315
### Changed

src/JsonSchema/Tool/Validator/UriValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function isValid(string $uri): bool
2121

2222
// RFC 3986: Non-Hierarchical URIs (mailto, data, urn, news)
2323
$nonHierarchicalPattern = '/^
24-
(mailto|data|urn|news|tel): # Only allow known non-hierarchical schemes
24+
(mailto|data|urn|news|tel|file): # Only allow known non-hierarchical schemes
2525
(.+) # Must contain at least one character after scheme
2626
$/ix';
2727

tests/Tool/Validator/UriValidatorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function validUriDataProvider(): \Generator
3434
yield 'OASIS URN URI' => ['uri' => 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'];
3535
yield 'Custom URI with underscore' => ['uri' => 'custom://reg_name/path/file.json'];
3636
yield 'Custom URI with tilde' => ['uri' => 'custom://reg~name/path/file.json'];
37+
yield 'File URI with implicit localhost (empty host)' => ['uri' => 'file:///path/to/file.txt'];
38+
yield 'File URI with explicit host' => ['uri' => 'file://some-host/path/to/file.txt'];
39+
yield 'File URI without any host' => ['uri' => 'file:/path/to/file.txt'];
3740
}
3841

3942
public function invalidUriDataProvider(): \Generator

0 commit comments

Comments
 (0)