| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "validation of URI References", |
| 4 |
"schema": { |
| 5 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 6 |
"format": "uri-reference" |
| 7 |
}, |
| 8 |
"tests": [ |
| 9 |
{ |
| 10 |
"description": "all string formats ignore integers", |
| 11 |
"data": 12, |
| 12 |
"valid": true |
| 13 |
}, |
| 14 |
{ |
| 15 |
"description": "all string formats ignore floats", |
| 16 |
"data": 13.7, |
| 17 |
"valid": true |
| 18 |
}, |
| 19 |
{ |
| 20 |
"description": "all string formats ignore objects", |
| 21 |
"data": {}, |
| 22 |
"valid": true |
| 23 |
}, |
| 24 |
{ |
| 25 |
"description": "all string formats ignore arrays", |
| 26 |
"data": [], |
| 27 |
"valid": true |
| 28 |
}, |
| 29 |
{ |
| 30 |
"description": "all string formats ignore booleans", |
| 31 |
"data": false, |
| 32 |
"valid": true |
| 33 |
}, |
| 34 |
{ |
| 35 |
"description": "all string formats ignore nulls", |
| 36 |
"data": null, |
| 37 |
"valid": true |
| 38 |
}, |
| 39 |
{ |
| 40 |
"description": "a valid URI", |
| 41 |
"data": "http://foo.bar/?baz=qux#quux", |
| 42 |
"valid": true |
| 43 |
}, |
| 44 |
{ |
| 45 |
"description": "a valid protocol-relative URI Reference", |
| 46 |
"data": "//foo.bar/?baz=qux#quux", |
| 47 |
"valid": true |
| 48 |
}, |
| 49 |
{ |
| 50 |
"description": "a valid relative URI Reference", |
| 51 |
"data": "/abc", |
| 52 |
"valid": true |
| 53 |
}, |
| 54 |
{ |
| 55 |
"description": "an invalid URI Reference", |
| 56 |
"data": "\\\\WINDOWS\\fileshare", |
| 57 |
"valid": false |
| 58 |
}, |
| 59 |
{ |
| 60 |
"description": "a valid URI Reference", |
| 61 |
"data": "abc", |
| 62 |
"valid": true |
| 63 |
}, |
| 64 |
{ |
| 65 |
"description": "a valid URI fragment", |
| 66 |
"data": "#fragment", |
| 67 |
"valid": true |
| 68 |
}, |
| 69 |
{ |
| 70 |
"description": "an invalid URI fragment", |
| 71 |
"data": "#frag\\ment", |
| 72 |
"valid": false |
| 73 |
}, |
| 74 |
{ |
| 75 |
"description": "unescaped non US-ASCII characters", |
| 76 |
"data": "/foobar®.txt", |
| 77 |
"valid": false |
| 78 |
}, |
| 79 |
{ |
| 80 |
"description": "invalid backslash character", |
| 81 |
"data": "https://example.org/foobar\\.txt", |
| 82 |
"valid": false |
| 83 |
}, |
| 84 |
{ |
| 85 |
"description": "URI with leading-zero IPv4 is structurally valid as a reg-name", |
| 86 |
"comment": "RFC 3986, Section 3.2.2: If an IP literal fails strict IPv4address parsing, it falls back to reg-name. A string of digits and dots is valid under unreserved characters. JSON Schema format asserts syntax, not scheme-specific DNS semantics.", |
| 87 |
"data": "http://087.10.0.1/", |
| 88 |
"valid": true |
| 89 |
}, |
| 90 |
{ |
| 91 |
"description": "URI with out-of-bounds IPv4 is structurally valid as a reg-name", |
| 92 |
"comment": "RFC 3986, Section 3.2.2: Fallback to reg-name allows digits and dots.", |
| 93 |
"data": "http://999.999.999.999/", |
| 94 |
"valid": true |
| 95 |
}, |
| 96 |
{ |
| 97 |
"description": "an empty URI reference", |
| 98 |
"comment": "RFC 3986, Section 4.2: relative-part includes path-empty, which is zero characters.", |
| 99 |
"data": "", |
| 100 |
"valid": true |
| 101 |
}, |
| 102 |
{ |
| 103 |
"description": "a query-only reference", |
| 104 |
"comment": "RFC 3986, Section 4.2: relative-ref = relative-part [ \"?\" query ] [ \"#\" fragment ], so a query with an empty path is a reference.", |
| 105 |
"data": "?query=1", |
| 106 |
"valid": true |
| 107 |
}, |
| 108 |
{ |
| 109 |
"description": "a network-path reference with an empty authority", |
| 110 |
"comment": "RFC 3986, Section 3.2.2: host = IP-literal / IPv4address / reg-name, and reg-name may be empty.", |
| 111 |
"data": "//", |
| 112 |
"valid": true |
| 113 |
}, |
| 114 |
{ |
| 115 |
"description": "an incomplete percent-encoding", |
| 116 |
"comment": "RFC 3986, Section 2.1: pct-encoded = \"%\" HEXDIG HEXDIG.", |
| 117 |
"data": "/%zz", |
| 118 |
"valid": false |
| 119 |
}, |
| 120 |
{ |
| 121 |
"description": "a double quote in a path", |
| 122 |
"comment": "RFC 3986, Appendix A: pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\", and the double quote is in none of them.", |
| 123 |
"data": "/a\"b", |
| 124 |
"valid": false |
| 125 |
}, |
| 126 |
{ |
| 127 |
"description": "square brackets outside an authority", |
| 128 |
"comment": "RFC 3986, Section 3.2.2: square brackets are reserved for an IP-literal inside the authority. path-absolute is built from pchar, which excludes them.", |
| 129 |
"data": "/[::1]", |
| 130 |
"valid": false |
| 131 |
}, |
| 132 |
{ |
| 133 |
"description": "a non-numeric port in a network-path reference", |
| 134 |
"comment": "RFC 3986, Section 3.2.3: port = *DIGIT. reg-name admits no colon, so the text after the colon can only be a port.", |
| 135 |
"data": "//example.com:abc/p", |
| 136 |
"valid": false |
| 137 |
}, |
| 138 |
{ |
| 139 |
"description": "more than one at-sign in the authority", |
| 140 |
"comment": "RFC 3986, Section 3.2: authority = [ userinfo \"@\" ] host [ \":\" port ]. Neither userinfo nor host admits a literal at-sign.", |
| 141 |
"data": "//a@[email protected]/", |
| 142 |
"valid": false |
| 143 |
}, |
| 144 |
{ |
| 145 |
"description": "a leading zero in the IPv4 part of an IPv6 literal", |
| 146 |
"comment": "RFC 3986, Section 3.2.2: inside an IP-literal the dotted quad must be an IPv4address, and dec-octet has no leading-zero alternative. There is no reg-name fallback inside brackets.", |
| 147 |
"data": "//[::ffff:192.168.0.01]/p", |
| 148 |
"valid": false |
| 149 |
}, |
| 150 |
{ |
| 151 |
"description": "a colon in the first segment of a relative-path reference", |
| 152 |
"comment": "RFC 3986, Section 4.2: relative-part uses path-noscheme, whose first segment is segment-nz-nc - a non-zero-length segment without any colon. A scheme must start with ALPHA, so 1:b cannot be read as a URI either.", |
| 153 |
"data": "1:b", |
| 154 |
"valid": false |
| 155 |
}, |
| 156 |
{ |
| 157 |
"description": "a colon in the first segment preceded by a dot-segment", |
| 158 |
"comment": "RFC 3986, Section 4.2: \"Such a segment must be preceded by a dot-segment (e.g., \\\"./this:that\\\") to make a relative-path reference.\"", |
| 159 |
"data": "./this:that", |
| 160 |
"valid": true |
| 161 |
}, |
| 162 |
{ |
| 163 |
"description": "a trailing line feed", |
| 164 |
"comment": "RFC 3986, Appendix A: no production admits %x0A.", |
| 165 |
"data": "/p\n", |
| 166 |
"valid": false |
| 167 |
}, |
| 168 |
{ |
| 169 |
"description": "an uppercase version character in an IPvFuture literal", |
| 170 |
"comment": "RFC 3986, Section 3.2.2 gives IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" ), and RFC 5234, Section 2.3 makes ABNF literals case-insensitive.", |
| 171 |
"data": "//[V1.fe]/p", |
| 172 |
"valid": true |
| 173 |
} |
| 174 |
] |
| 175 |
} |
| 176 |
] |