Skip to content

Commit a3f5eff

Browse files
authored
Upgrade Core to e2f82c8a43a3a9b2ff53171fa3243eaa451f8979 (#851)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 50fdeec commit a3f5eff

77 files changed

Lines changed: 1858 additions & 916 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DEPENDENCIES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
2-
core https://github.com/sourcemeta/core a75b850e323ad3713c6ec907424600107892028b
2+
core https://github.com/sourcemeta/core e2f82c8a43a3a9b2ff53171fa3243eaa451f8979
33
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite 60755c1097769e313fae3ec4d63bcc9d49b5d2d5
44
jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72
55
jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd

src/configuration/parse.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,22 @@ auto Configuration::from_json(const sourcemeta::core::JSON &value,
5858
!value.defines("dependencies") || value.at("dependencies").is_object(),
5959
"The dependencies property must be an object", {"dependencies"});
6060

61+
const sourcemeta::core::JSON null_value{nullptr};
6162
result.title =
6263
sourcemeta::core::from_json<decltype(result.title)::value_type>(
63-
value.at_or("title", sourcemeta::core::JSON{nullptr}));
64+
value.at_or("title", null_value));
6465
result.description =
6566
sourcemeta::core::from_json<decltype(result.description)::value_type>(
66-
value.at_or("description", sourcemeta::core::JSON{nullptr}));
67+
value.at_or("description", null_value));
6768
result.email =
6869
sourcemeta::core::from_json<decltype(result.email)::value_type>(
69-
value.at_or("email", sourcemeta::core::JSON{nullptr}));
70+
value.at_or("email", null_value));
7071
result.github =
7172
sourcemeta::core::from_json<decltype(result.github)::value_type>(
72-
value.at_or("github", sourcemeta::core::JSON{nullptr}));
73+
value.at_or("github", null_value));
7374
result.website =
7475
sourcemeta::core::from_json<decltype(result.website)::value_type>(
75-
value.at_or("website", sourcemeta::core::JSON{nullptr}));
76+
value.at_or("website", null_value));
7677

7778
if (value.defines("path")) {
7879
const std::filesystem::path path{value.at("path").to_string()};
@@ -113,7 +114,7 @@ auto Configuration::from_json(const sourcemeta::core::JSON &value,
113114

114115
result.default_dialect =
115116
sourcemeta::core::from_json<decltype(result.default_dialect)::value_type>(
116-
value.at_or("defaultDialect", sourcemeta::core::JSON{nullptr}));
117+
value.at_or("defaultDialect", null_value));
117118

118119
if (value.defines("extension")) {
119120
result.extension.clear();

src/frame/frame.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,24 @@ auto supports_id_anchors(
321321
}
322322
}
323323

324+
// Generic URI normalisation only decodes unreserved characters (see RFC 3986,
325+
// section 6.2.2.2), so a reference destination may still spell its JSON
326+
// Pointer fragment with percent-encoded octets. Re-serialise such fragments
327+
// from their parsed form so that reference destinations match the URIs that
328+
// locations are framed under
329+
auto canonicalize_pointer_fragment(sourcemeta::core::URI &uri) -> void {
330+
const auto fragment{uri.fragment()};
331+
if (!fragment.has_value() ||
332+
fragment.value().find('%') == std::string_view::npos) {
333+
return;
334+
}
335+
336+
const auto destination{sourcemeta::core::fragment_to_pointer(uri)};
337+
if (destination.has_value()) {
338+
uri.fragment(sourcemeta::core::to_string(destination.value()));
339+
}
340+
}
341+
324342
auto set_base_and_fragment(
325343
sourcemeta::blaze::SchemaFrame::ReferencesEntry &entry) -> void {
326344
const std::string_view destination_view{entry.destination};
@@ -1042,6 +1060,7 @@ auto SchemaFrame::analyse(const sourcemeta::core::JSON &root,
10421060
}
10431061

10441062
ref.canonicalize();
1063+
canonicalize_pointer_fragment(ref);
10451064
auto ref_pointer{common_pointer_weak};
10461065
ref_pointer.push_back(std::cref(KEYWORD_REF));
10471066
const auto [it, inserted] = this->references_.insert_or_assign(
@@ -1127,6 +1146,7 @@ auto SchemaFrame::analyse(const sourcemeta::core::JSON &root,
11271146
}
11281147

11291148
ref.canonicalize();
1149+
canonicalize_pointer_fragment(ref);
11301150
auto ref_string{ref.recompose()};
11311151

11321152
// Note that here we cannot enforce the bookending requirement,

test/frame/frame_2020_12_test.cc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,76 @@ TEST(Frame_2020_12, ref_with_id) {
29322932
"https://www.sourcemeta.com/schema#/$defs/string");
29332933
}
29342934

2935+
TEST(Frame_2020_12, ref_with_percent_encoded_colon_in_fragment) {
2936+
const sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({
2937+
"$schema": "https://json-schema.org/draft/2020-12/schema",
2938+
"$ref": "#/$defs/https%3A~1~1example.com~1schema~1type",
2939+
"$defs": {
2940+
"https://example.com/schema/type": { "type": "string" }
2941+
}
2942+
})JSON");
2943+
2944+
sourcemeta::blaze::SchemaFrame frame{
2945+
sourcemeta::blaze::SchemaFrame::Mode::References};
2946+
frame.analyse(document, sourcemeta::blaze::schema_walker,
2947+
sourcemeta::blaze::schema_resolver);
2948+
2949+
EXPECT_EQ(frame.locations().size(), 6);
2950+
2951+
// JSON Pointers
2952+
2953+
EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA(
2954+
frame, "", "", "https://json-schema.org/draft/2020-12/schema",
2955+
JSON_Schema_2020_12, std::nullopt, false, false);
2956+
EXPECT_ANONYMOUS_FRAME_STATIC_POINTER(
2957+
frame, "#/$schema", "/$schema",
2958+
"https://json-schema.org/draft/2020-12/schema", JSON_Schema_2020_12, "",
2959+
false, false);
2960+
EXPECT_ANONYMOUS_FRAME_STATIC_POINTER(
2961+
frame, "#/$ref", "/$ref", "https://json-schema.org/draft/2020-12/schema",
2962+
JSON_Schema_2020_12, "", false, false);
2963+
EXPECT_ANONYMOUS_FRAME_STATIC_POINTER(
2964+
frame, "#/$defs", "/$defs",
2965+
"https://json-schema.org/draft/2020-12/schema", JSON_Schema_2020_12, "",
2966+
false, false);
2967+
EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA(
2968+
frame, "#/$defs/https:~1~1example.com~1schema~1type",
2969+
"/$defs/https:~1~1example.com~1schema~1type",
2970+
"https://json-schema.org/draft/2020-12/schema", JSON_Schema_2020_12, "",
2971+
false, true);
2972+
EXPECT_ANONYMOUS_FRAME_STATIC_POINTER(
2973+
frame, "#/$defs/https:~1~1example.com~1schema~1type/type",
2974+
"/$defs/https:~1~1example.com~1schema~1type/type",
2975+
"https://json-schema.org/draft/2020-12/schema", JSON_Schema_2020_12,
2976+
"/$defs/https:~1~1example.com~1schema~1type", false, true);
2977+
2978+
// References
2979+
2980+
EXPECT_EQ(frame.references().size(), 2);
2981+
2982+
EXPECT_STATIC_REFERENCE(
2983+
frame, "/$schema", "https://json-schema.org/draft/2020-12/schema",
2984+
"https://json-schema.org/draft/2020-12/schema", std::nullopt,
2985+
"https://json-schema.org/draft/2020-12/schema");
2986+
EXPECT_STATIC_REFERENCE(frame, "/$ref",
2987+
"#/$defs/https:~1~1example.com~1schema~1type", "",
2988+
"/$defs/https:~1~1example.com~1schema~1type",
2989+
"#/$defs/https%3A~1~1example.com~1schema~1type");
2990+
2991+
// Reachability
2992+
2993+
EXPECT_FRAME_LOCATION_REACHABLE(frame, Static, "", frame.root());
2994+
EXPECT_FRAME_LOCATION_REACHABLE(frame, Static,
2995+
"#/$defs/https:~1~1example.com~1schema~1type",
2996+
frame.root());
2997+
2998+
EXPECT_FRAME_LOCATION_NON_REACHABLE(
2999+
frame, Static, "", "#/$defs/https:~1~1example.com~1schema~1type");
3000+
EXPECT_FRAME_LOCATION_REACHABLE(
3001+
frame, Static, "#/$defs/https:~1~1example.com~1schema~1type",
3002+
"#/$defs/https:~1~1example.com~1schema~1type");
3003+
}
3004+
29353005
TEST(Frame_2020_12, ref_from_definitions) {
29363006
const sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({
29373007
"$id": "https://www.sourcemeta.com/schema",

vendor/core/src/core/crypto/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/core/src/core/crypto/crypto_fnv128.cc

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)