Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 8018e9d85ef6fc0fd9ccd11c2ae438789214b00a
core https://github.com/sourcemeta/core cd56ace324a42f067b4b8f651f73b9aa0313ca2a
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite aa77c9d343a2da809d4c8734f473c4d5b5d80f14
jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72
jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From 8a0745f18ef6c2fc281c62ff3fbea712c72de76f Mon Sep 17 00:00:00 2001
From: Juan Cruz Viotti <jviotti@sourcemeta.com>
Date: Thu, 28 May 2026 10:27:12 -0400
Subject: [PATCH] Update draft3 ecmascript-regex for ES2018 lookbehind

Lookbehind assertions were added to ECMA-262 in ES2018 and are
accepted by every modern JavaScript engine, so "(?<=foo)bar" is in
fact a valid ECMA 262 regex. The existing test asserting otherwise
predates that addition and no longer reflects the specification.

Flip the existing lookbehind case to valid and refresh its
description. Add a new case using Python's "(?P<name>x)" named-group
syntax which remains genuinely outside ECMA 262, since ECMA uses
"(?<name>x)" without the leading P.
---
tests/draft3/optional/format/ecmascript-regex.json | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/draft3/optional/format/ecmascript-regex.json b/tests/draft3/optional/format/ecmascript-regex.json
index 03fe977..2ffc929 100644
--- a/tests/draft3/optional/format/ecmascript-regex.json
+++ b/tests/draft3/optional/format/ecmascript-regex.json
@@ -9,8 +9,13 @@
"valid": true
},
{
- "description": "ECMA 262 has no support for lookbehind",
+ "description": "ECMA 262 supports lookbehind since ES2018",
"data": "(?<=foo)bar",
+ "valid": true
+ },
+ {
+ "description": "ECMA 262 does not support Python-style named groups",
+ "data": "(?P<name>x)",
"valid": false
}
]
--
2.54.0

8 changes: 2 additions & 6 deletions src/compiler/default_compiler_draft3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2529,9 +2529,7 @@ auto compiler_draft3_validation_format(const Context &context,
} else if (name == "uri") {
type = ValueStringType::URI;
} else if (name == "date") {
throw sourcemeta::blaze::CompilerError(
schema_context.base, to_pointer(schema_context.relative_pointer),
"The \"date\" format is not supported in assertion mode yet");
type = ValueStringType::Date;
} else if (name == "time") {
throw sourcemeta::blaze::CompilerError(
schema_context.base, to_pointer(schema_context.relative_pointer),
Expand All @@ -2541,9 +2539,7 @@ auto compiler_draft3_validation_format(const Context &context,
schema_context.base, to_pointer(schema_context.relative_pointer),
"The \"utc-millisec\" format is not supported in assertion mode yet");
} else if (name == "regex") {
throw sourcemeta::blaze::CompilerError(
schema_context.base, to_pointer(schema_context.relative_pointer),
"The \"regex\" format is not supported in assertion mode yet");
type = ValueStringType::Regex;
} else if (name == "color") {
throw sourcemeta::blaze::CompilerError(
schema_context.base, to_pointer(schema_context.relative_pointer),
Expand Down
2 changes: 2 additions & 0 deletions src/evaluator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ target_link_libraries(sourcemeta_blaze_evaluator PUBLIC
sourcemeta::core::dns)
target_link_libraries(sourcemeta_blaze_evaluator PUBLIC
sourcemeta::core::time)
target_link_libraries(sourcemeta_blaze_evaluator PUBLIC
sourcemeta::core::crypto)
24 changes: 24 additions & 0 deletions src/evaluator/evaluator_describe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,9 @@ auto describe(const bool valid, const Instruction &step,
case ValueStringType::Email:
message << " email address";
break;
case ValueStringType::IDNEmail:
message << " internationalized email address";
break;
case ValueStringType::IPv4:
message << " IPv4 address";
break;
Expand All @@ -2135,12 +2138,33 @@ auto describe(const bool valid, const Instruction &step,
case ValueStringType::Hostname:
message << " hostname";
break;
case ValueStringType::IDNHostname:
message << " internationalized hostname";
break;
case ValueStringType::DateTime:
message << " RFC 3339 date-time";
break;
case ValueStringType::Date:
message << " RFC 3339 full-date";
break;
case ValueStringType::Time:
message << " RFC 3339 full-time";
break;
case ValueStringType::Duration:
message << " RFC 3339 duration";
break;
case ValueStringType::JSONPointer:
message << " JSON Pointer";
break;
case ValueStringType::RelativeJSONPointer:
message << " relative JSON Pointer";
break;
case ValueStringType::UUID:
message << " UUID";
break;
case ValueStringType::Regex:
message << " ECMA-262 regular expression";
break;
default:
return unknown();
}
Expand Down
26 changes: 26 additions & 0 deletions src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

#include <sourcemeta/blaze/evaluator.h>

#include <sourcemeta/core/crypto.h>
#include <sourcemeta/core/dns.h>
#include <sourcemeta/core/email.h>
#include <sourcemeta/core/ip.h>
#include <sourcemeta/core/regex.h>
#include <sourcemeta/core/time.h>
#include <sourcemeta/core/uritemplate.h>

Expand Down Expand Up @@ -882,6 +884,9 @@ INSTRUCTION_HANDLER(AssertionStringType) {
case ValueStringType::Email:
result = is_email(target);
break;
case ValueStringType::IDNEmail:
result = is_idn_email(target);
break;
case ValueStringType::IPv4:
result = is_ipv4(target);
break;
Expand All @@ -891,12 +896,33 @@ INSTRUCTION_HANDLER(AssertionStringType) {
case ValueStringType::Hostname:
result = is_hostname(target);
break;
case ValueStringType::IDNHostname:
result = is_idn_hostname(target);
break;
case ValueStringType::DateTime:
result = is_rfc3339_datetime(target);
break;
case ValueStringType::Date:
result = is_rfc3339_fulldate(target);
break;
case ValueStringType::Time:
result = is_rfc3339_fulltime(target);
break;
case ValueStringType::Duration:
result = is_rfc3339_duration(target);
break;
case ValueStringType::JSONPointer:
result = is_pointer(target);
break;
case ValueStringType::RelativeJSONPointer:
result = is_relative_pointer(target);
break;
case ValueStringType::UUID:
result = is_uuid_like(target);
break;
case ValueStringType::Regex:
result = is_regex_ecma(target);
break;
default:
std::unreachable();
}
Expand Down
10 changes: 9 additions & 1 deletion src/evaluator/include/sourcemeta/blaze/evaluator_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,19 @@ enum class ValueStringType : std::uint8_t {
URIReference,
URITemplate,
Email,
IDNEmail,
IPv4,
IPv6,
Hostname,
IDNHostname,
DateTime,
JSONPointer
Date,
Time,
Duration,
JSONPointer,
RelativeJSONPointer,
UUID,
Regex
};

/// @ingroup evaluator
Expand Down
Loading
Loading