Skip to content

Commit 4c53a6b

Browse files
Fix fragment-offset-range pattern escaping in single-quoted strings
The pattern and posix-pattern for fragment-offset-range use '\\.' (double backslash) in single-quoted YANG strings. Since single-quoted strings have no escape processing (RFC 7950 Section 6.1.3), '\\.' stores as literal backslash-backslash-dot, which in regex means "literal backslash followed by any character" — not the intended "literal dot". All other patterns in the OpenConfig models correctly use '\.' (single backslash) for literal dot matching in single-quoted strings (e.g. area-address in openconfig-isis-types.yang).
1 parent f87db50 commit 4c53a6b

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

regexp-tests/openconfig-packet-match-types-test.yang

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,23 @@ module openconfig-packet-match-types-test {
2626
pt:pattern-test-fail "66999..67890";
2727
pt:pattern-test-fail "70000..70000";
2828
}
29+
30+
leaf fragment-offset-range {
31+
type oc-pkt-match-types:fragment-offset-range;
32+
pt:pattern-test-pass "0..0";
33+
pt:pattern-test-pass "0..8191";
34+
pt:pattern-test-pass "8191..8191";
35+
pt:pattern-test-pass "100..200";
36+
pt:pattern-test-pass "00..00";
37+
pt:pattern-test-pass "0000..0000";
38+
pt:pattern-test-pass "1234..5678";
39+
pt:pattern-test-pass "7999..8191";
40+
pt:pattern-test-fail "100.200";
41+
pt:pattern-test-fail "0.8191";
42+
pt:pattern-test-fail "0..8192";
43+
pt:pattern-test-fail "8192..8192";
44+
pt:pattern-test-fail "9999..9999";
45+
pt:pattern-test-fail "10000..10000";
46+
pt:pattern-test-fail "-1..10";
47+
}
2948
}

release/models/acl/openconfig-packet-match-types.yang

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ module openconfig-packet-match-types {
383383
type string {
384384
pattern
385385
'(0{0,3}[0-9]|0{0,2}[1-9][0-9]|0?[1-9][0-9]{2}|[1-7][0-9]{3}|'
386-
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1])\\.\\.(0{0,3}[0-9]|'
386+
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1])\.\.(0{0,3}[0-9]|'
387387
+ '0{0,2}[1-9][0-9]|0?[1-9][0-9]{2}|[1-7][0-9]{3}|'
388388
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1])';
389389
oc-ext:posix-pattern
390390
'^((0{0,3}[0-9]|0{0,2}[1-9][0-9]|0?[1-9][0-9]{2}|[1-7][0-9]{3}|'
391-
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1])\\.\\.(0{0,3}[0-9]|'
391+
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1])\.\.(0{0,3}[0-9]|'
392392
+ '0{0,2}[1-9][0-9]|0?[1-9][0-9]{2}|[1-7][0-9]{3}|'
393393
+ '80[0-9]{2}|81[0-8][0-9]|819[0-1]))$';
394394
}

0 commit comments

Comments
 (0)