Skip to content

Commit 115a09e

Browse files
committed
fix: Skip validation of content due to security concerns
1 parent 65e95cd commit 115a09e

1 file changed

Lines changed: 1 addition & 30 deletions

File tree

src/JsonSchema/Constraints/Drafts/Draft2019/ContentConstraint.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,6 @@ public function __construct(?Factory $factory = null)
2121

2222
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
2323
{
24-
if (!property_exists($schema, 'contentMediaType') && !property_exists($schema, 'contentEncoding')) {
25-
return;
26-
}
27-
if (!is_string($value)) {
28-
return;
29-
}
30-
31-
$decodedValue = $value;
32-
33-
if (property_exists($schema, 'contentEncoding')) {
34-
if ($schema->contentEncoding === 'base64') {
35-
if (!preg_match('/^[A-Za-z0-9+\/=]+$/', $decodedValue)) {
36-
$this->addError(ConstraintError::CONTENT_ENCODING(), $path, ['contentEncoding' => $schema->contentEncoding]);
37-
38-
return;
39-
}
40-
$decodedValue = base64_decode($decodedValue);
41-
}
42-
}
43-
44-
if (property_exists($schema, 'contentMediaType')) {
45-
if ($schema->contentMediaType === 'application/json') {
46-
json_decode($decodedValue, false);
47-
if (json_last_error() === JSON_ERROR_NONE) {
48-
return;
49-
}
50-
}
51-
52-
$this->addError(ConstraintError::CONTENT_MEDIA_TYPE(), $path, ['contentMediaType' => $schema->contentMediaType]);
53-
}
24+
// See https://json-schema.org/draft/2019-09/json-schema-validation#rfc.section.8
5425
}
5526
}

0 commit comments

Comments
 (0)