corvus_json_schema 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -129,10 +129,10 @@ fn normalize_parts(scheme: Option<&str>, authority: Option<&str>, path: &str, qu
129
129
  Some("https") => Some(":443"),
130
130
  _ => None,
131
131
  };
132
- if let Some(port) = default_port {
133
- if a.ends_with(port) {
134
- a.truncate(a.len() - port.len());
135
- }
132
+ if let Some(port) = default_port
133
+ && a.ends_with(port)
134
+ {
135
+ a.truncate(a.len() - port.len());
136
136
  }
137
137
  if path.is_empty() {
138
138
  path = "/".to_string();
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CorvusJsonSchema
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -25,6 +25,9 @@ module CorvusJsonSchema
25
25
  draft4: 4, draft6: 6, draft7: 7, draft201909: 2019, draft202012: 2020
26
26
  }.freeze
27
27
 
28
+ # The seconds one match of a regular expression may take, unless compile is told otherwise.
29
+ DEFAULT_PATTERN_MATCH_LIMIT = 1.0
30
+
28
31
  RESULTS_LEVELS = { basic: 0, detailed: 1, verbose: 2 }.freeze
29
32
 
30
33
  # Compiles a schema (a Hash or Array, true or false, or JSON text) into a Validator.
@@ -33,12 +36,24 @@ module CorvusJsonSchema
33
36
  # $schema), assert_format (nil follows the vocabularies), assert_format_in_legacy_drafts, assert_content, formats (a
34
37
  # Hash of format name to a callable returning whether a string is valid), resolver (a callable from an absolute URI
35
38
  # to the document, as a Hash or JSON text, or nil when unknown), base_uri, entry_point (a reference such as
36
- # "#/$defs/item") and max_depth (of in-place recursion, default 128).
39
+ # "#/$defs/item"), max_depth (of in-place recursion, default 128) and pattern_match_limit (the seconds one match of
40
+ # a pattern or patternProperties regular expression may take, default 1. A match that takes longer is abandoned and
41
+ # the validation raises PatternMatchLimitError. nil or 0 turns the limit off, for a caller who trusts both the
42
+ # schema and the instances), regex_edition (the edition of ECMA-262 patterns are read with: :dialect, the default,
43
+ # which is ECMAScript 2020 for 2019-09 and 2020-12 and today's for the drafts before them, :current or :es2020) and
44
+ # regex_unicode_version (the version of Unicode they are read with: :default, Unicode 17 today, :latest, 13, 17 or
45
+ # 18).
46
+ #
47
+ # A schema that does not compile raises CompilationError, and one with a regular expression over a limit of size
48
+ # (1,048,576 bytes of pattern, 1,000 levels of groups) raises PatternTooLargeError, which is a CompilationError.
37
49
  def self.compile(schema, default_dialect: :draft202012, assert_format: nil, assert_format_in_legacy_drafts: false,
38
- assert_content: true, formats: nil, resolver: nil, base_uri: nil, entry_point: nil, max_depth: 128)
50
+ assert_content: true, formats: nil, resolver: nil, base_uri: nil, entry_point: nil, max_depth: 128,
51
+ pattern_match_limit: DEFAULT_PATTERN_MATCH_LIMIT, regex_edition: :dialect,
52
+ regex_unicode_version: :default)
39
53
  dialect = DIALECTS.fetch(default_dialect) { raise ArgumentError, "unknown dialect #{default_dialect.inspect}" }
40
54
  Native.compile(schema, dialect, assert_format, assert_format_in_legacy_drafts, assert_content, formats, resolver,
41
- base_uri, entry_point, Integer(max_depth))
55
+ base_uri, entry_point, Integer(max_depth), pattern_match_limit&.to_f, regex_edition.to_s,
56
+ regex_unicode_version.to_s)
42
57
  end
43
58
 
44
59
  # The version of the corvus-json-schema crate the extension was built from.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corvus_json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - endjin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-12 00:00:00.000000000 Z
11
+ date: 2026-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -37,6 +37,7 @@ files:
37
37
  - Cargo.toml
38
38
  - LICENSE
39
39
  - README.md
40
+ - THIRD-PARTY-NOTICES.txt
40
41
  - VERSIONHISTORY.md
41
42
  - ext/corvus_json_schema/Cargo.toml
42
43
  - ext/corvus_json_schema/clippy.toml