File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed
main/java/com/networknt/schema/format
test/java/com/networknt/schema/format Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ protected boolean validate(URI uri) {
17
17
}
18
18
}
19
19
20
- String query = uri .getQuery ();
20
+ String query = uri .getRawQuery ();
21
21
if (query != null ) {
22
22
// [ and ] must be percent encoded
23
23
if (query .indexOf ('[' ) != -1 || query .indexOf (']' ) != -1 ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ protected boolean validate(URI uri) {
14
14
return false ;
15
15
}
16
16
}
17
- String query = uri .getQuery ();
17
+ String query = uri .getRawQuery ();
18
18
if (query != null ) {
19
19
// [ and ] must be percent encoded
20
20
if (query .indexOf ('[' ) != -1 || query .indexOf (']' ) != -1 ) {
Original file line number Diff line number Diff line change @@ -56,6 +56,20 @@ void queryWithBracketsShouldFail() {
56
56
InputFormat .JSON );
57
57
assertFalse (messages .isEmpty ());
58
58
}
59
+
60
+ @ Test
61
+ void queryWithEncodedBracketsShouldPass () {
62
+ String schemaData = "{\r \n "
63
+ + " \" format\" : \" iri\" \r \n "
64
+ + "}" ;
65
+
66
+ SchemaValidatorsConfig config = new SchemaValidatorsConfig ();
67
+ config .setFormatAssertionsEnabled (true );
68
+ JsonSchema schema = JsonSchemaFactory .getInstance (VersionFlag .V202012 ).getSchema (schemaData , config );
69
+ Set <ValidationMessage > messages = schema .validate ("\" https://test.com/assets/product.pdf?filter%5Btest%5D=1\" " ,
70
+ InputFormat .JSON );
71
+ assertTrue (messages .isEmpty ());
72
+ }
59
73
60
74
@ Test
61
75
void iriShouldPass () {
Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ void queryWithBracketsShouldFail() {
57
57
assertFalse (messages .isEmpty ());
58
58
}
59
59
60
+ @ Test
61
+ void queryWithEncodedBracketsShouldPass () {
62
+ String schemaData = "{\r \n "
63
+ + " \" format\" : \" iri-reference\" \r \n "
64
+ + "}" ;
65
+
66
+ SchemaValidatorsConfig config = new SchemaValidatorsConfig ();
67
+ config .setFormatAssertionsEnabled (true );
68
+ JsonSchema schema = JsonSchemaFactory .getInstance (VersionFlag .V202012 ).getSchema (schemaData , config );
69
+ Set <ValidationMessage > messages = schema .validate ("\" https://test.com/assets/product.pdf?filter%5Btest%5D=1\" " ,
70
+ InputFormat .JSON );
71
+ assertTrue (messages .isEmpty ());
72
+ }
73
+
60
74
@ Test
61
75
void iriShouldPass () {
62
76
String schemaData = "{\r \n "
You can’t perform that action at this time.
0 commit comments