Skip to content

Commit e9601b4

Browse files
Bump test-suites/schema-test-suite from e99b24c to be58fa9 (#356)
Bumps [test-suites/schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) from `e99b24c` to `be58fa9`. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/be58fa98d5f79bb8d20f45a15e540332669ad947"><code>be58fa9</code></a> Merge pull request <a href="https://redirect.github.com/json-schema-org/JSON-Schema-Test-Suite/issues/791">#791</a> from json-schema-org/ether/fix-draft-next-removal</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/acaece38e8d5f2373052c77110159db5c11b63a9"><code>acaece3</code></a> stop using the term &quot;draft&quot; to mean &quot;version&quot;, and fix the remaining mentions...</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/980e10529f4aba741403a8466cace29a97e67a22"><code>980e105</code></a> Merge pull request <a href="https://redirect.github.com/json-schema-org/JSON-Schema-Test-Suite/issues/790">#790</a> from dylankerr-bis/add-test-sibling-nested-ref-id</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/b5037ed7ac94f2da1865969c95f700259c347822"><code>b5037ed</code></a> Add test for sibling $ref and $id in nested schema to v1 suite</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/4cf559962d6dd01aa576e9b8889d771df70d9e50"><code>4cf5599</code></a> Merge pull request <a href="https://redirect.github.com/json-schema-org/JSON-Schema-Test-Suite/issues/776">#776</a> from davishmcclurg/idn-hostname-separators</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/a930db4328776cb9fe4ef9297912dacf5157366b"><code>a930db4</code></a> Shorten test descriptions to appease ci</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/aab08752cf060a333bc44e68ad7294aa20024107"><code>aab0875</code></a> Updates form PR feedback</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/081a16a76aff9921c54cc549508ce8afaf768483"><code>081a16a</code></a> Test IDN label separators separate labels</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/658c8cf9f355b9b4e378d4af7201638f1cf802e2"><code>658c8cf</code></a> Test IDN label separator in <code>hostname</code> format</li> <li><a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/commit/38c04b830a2aa4fa388ec48501268069ef02b432"><code>38c04b8</code></a> Test label separator position in hostname formats</li> <li>Additional commits viewable in <a href="https://github.com/json-schema-org/JSON-Schema-Test-Suite/compare/e99b24c92006fd83803be511d77278910986d6aa...be58fa98d5f79bb8d20f45a15e540332669ad947">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Oleg Smirnov <oleg31101996@gmail.com>
1 parent 35e9b94 commit e9601b4

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

json-schema-validator/src/commonMain/kotlin/io/github/optimumcode/json/schema/internal/SchemaLoader.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,46 @@ private fun Uri.appendPathToParent(path: String): Uri {
712712
}
713713
}.appendEncodedPath(path)
714714
.build()
715+
.normalizeUri()
715716
}
716717

718+
private fun Uri.normalizeUri(): Uri {
719+
if (pathSegments.none { it in RELATIVE_PATH_SEGMENTS }) {
720+
// Nothing to normalize
721+
return this
722+
}
723+
724+
val newPathSegments = ArrayDeque<String>()
725+
for (segment in pathSegments) {
726+
when (segment) {
727+
SAME_LEVEL_SEGMENT -> { // skip
728+
}
729+
730+
PARENT_LEVEL_SEGMENT ->
731+
if (newPathSegments.isEmpty()) {
732+
error("cannot normalize URI '$this'. Path goes beyond root")
733+
} else {
734+
newPathSegments.removeLast()
735+
}
736+
737+
else -> newPathSegments.addLast(segment)
738+
}
739+
}
740+
741+
return buildUpon()
742+
.encodedPath(null)
743+
.apply {
744+
for (segment in newPathSegments) {
745+
appendEncodedPath(segment)
746+
}
747+
}.build()
748+
}
749+
750+
private const val SAME_LEVEL_SEGMENT = "."
751+
private const val PARENT_LEVEL_SEGMENT = ".."
752+
753+
private val RELATIVE_PATH_SEGMENTS = setOf(SAME_LEVEL_SEGMENT, PARENT_LEVEL_SEGMENT)
754+
717755
private val ANCHOR_REGEX: Regex = "^[A-Za-z][A-Za-z0-9-_:.]*$".toRegex()
718756

719757
private fun Uri.buildRefId(): RefId = RefId(this)

json-schema-validator/src/commonMain/kotlin/io/github/optimumcode/json/schema/internal/formats/IdnHostnameFormatValidator.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal object IdnHostnameFormatValidator : AbstractStringFormatValidator() {
4848
if (value.isEmpty()) {
4949
return FormatValidator.Invalid()
5050
}
51-
if (value.length == 1 && isLabelSeparator(value[0])) {
51+
if (isLabelSeparator(value[0]) || isLabelSeparator(value[value.lastIndex])) {
5252
return FormatValidator.Invalid()
5353
}
5454

@@ -113,6 +113,11 @@ internal object IdnHostnameFormatValidator : AbstractStringFormatValidator() {
113113
return false
114114
}
115115

116+
if (unicode.isEmpty()) {
117+
// empty labels are not valid
118+
return false
119+
}
120+
116121
// https://datatracker.ietf.org/doc/html/rfc5891#section-4.2.3.1
117122
if (unicode[0] == '-' || unicode.codePointBefore(unicode.length) == '-'.code) {
118123
// cannot start or end with hyphen

json-schema-validator/src/commonTest/kotlin/io/github/optimumcode/json/schema/assertions/general/format/JsonSchemaIdnHostnameFormatValidationTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class JsonSchemaIdnHostnameFormatValidationTest : FunSpec() {
3333
listOf(
3434
TestCase("", "empty value"),
3535
TestCase(".", "single separator"),
36+
TestCase(".example", "leading separator"),
37+
TestCase("example.", "trailing separator"),
38+
TestCase("example..com", "two separators in a row"),
3639
TestCase("\u3002", "single separator U+3002"),
3740
TestCase("\uFF0E", "single separator U+FF0E"),
3841
TestCase("\uFF61", "single separator U+FF61"),

json-schema-validator/src/commonTest/kotlin/io/github/optimumcode/json/schema/base/JsonSchemaTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class JsonSchemaTest : FunSpec() {
115115
"http://example.com/other.json",
116116
"http://example.com/other.json#",
117117
"http://example.com/root.json#/definitions/B",
118+
"./other.json",
118119
),
119120
"definition X" to
120121
listOf(
@@ -136,7 +137,8 @@ class JsonSchemaTest : FunSpec() {
136137
"http://example.com/root.json#/definitions/C",
137138
),
138139
).forEach { (refDestination, possibleRefs) ->
139-
possibleRefs.asSequence()
140+
possibleRefs
141+
.asSequence()
140142
.flatMapIndexed { index, ref ->
141143
val uri = Uri.parse(ref)
142144
val caseNumber = index + 1

0 commit comments

Comments
 (0)