Skip to content

Commit bd62b35

Browse files
committed
Improve validation of UUri during deserialization
1 parent 022312f commit bd62b35

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/org/eclipse/uprotocol/uri/serializer/UriSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class UriSerializer {
3535
*/
3636
public static final String SCHEME_UP = "up";
3737

38-
private static final Pattern AUTHORITY_PATTERN = Pattern.compile("^[a-z0-9-._~]{1,128}$");
38+
private static final Pattern AUTHORITY_PATTERN = Pattern.compile("^[a-z0-9-._~]{0,128}$");
3939

4040
private UriSerializer() {
4141
// prevent instantiation

src/test/resources/features/uuri_uri_serialization.feature

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Feature: String representation of endpoint identfiers (UUri)
3434
Examples:
3535
| authority_name | entity_id | version | resource_id | uri_string |
3636
| "" | 0x00000001 | 0x01 | 0xa1fb | up:/1/1/A1FB |
37+
| "192.168.1.1" | 0x00000001 | 0x01 | 0xa1fb | up://192.168.1.1/1/1/A1FB |
38+
| "[2001::7]" | 0x00000001 | 0x01 | 0xa1fb | up://[2001::7]/1/1/A1FB |
3739
| "my_vin" | 0x10000001 | 0x02 | 0x001a | up://my_vin/10000001/2/1A |
3840
| "*" | 0x00000101 | 0xa0 | 0xa1fb | up://*/101/A0/A1FB |
3941
| "mcu1" | 0x0000FFFF | 0x01 | 0xa1fb | up://mcu1/FFFF/1/A1FB |
@@ -69,7 +71,6 @@ Feature: String representation of endpoint identfiers (UUri)
6971
| "/" | not a URI |
7072
| "//" | not a URI |
7173
| "//vcu.my_vin" | just an authority |
72-
| "//VCU" | authority with uppercase characters |
7374
| "//vcu.my_vin//1/A1FB" | missing entity ID |
7475
| "//vcu.my_vin/101//A1FB" | missing version |
7576
| "//vcu.my_vin/101/1/" | missing resource ID |
@@ -79,6 +80,8 @@ Feature: String representation of endpoint identfiers (UUri)
7980
| "//vcu.my_vin/101/1/A#foo" | URI with fragment |
8081
| "//vcu.my-vin:1516/101/1/A" | server-based authority with port |
8182
| "//user:pwd@vcu.my-vin/101/1/A" | server-based authority with user info |
83+
| "//[2001:db87aa::8]/101/1/A" | invalid IP literal authority |
84+
| "//MY_VIN/101/1/A" | registry-based authority with uppercase characters |
8285
| "//reg_based:1516/101/1/A" | registry-based authority name with invalid characters |
8386
| "up://vcu.my-vin/1G1/1/A1FB" | non-hex entity ID |
8487
| "/123456789/1/A1FB" | entity ID exceeds max length |

0 commit comments

Comments
 (0)