cddl 0.11.5 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/cddl +4 -1
- data/cddl.gemspec +1 -1
- data/data/cddl.abnf +21 -9
- data/lib/cddl.rb +38 -3
- data/test-data/b64u-strict.cddl +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a29d5d85e11598502b09d04e3b08a7ada9b6d0d8a9eb0e425bb01da81b92532b
|
4
|
+
data.tar.gz: 61c2a191c264c34600f0b66a8e7cfb2ea1359f3954676828a56a63aa25e3015c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671d119f1cb328151c0631cbcd808f5a32d1f82d6c715a64cb5e5c9702b3452c996278a6b5055613de74b00f76489a9874037b336ac3a760947d4a2526d84cc9
|
7
|
+
data.tar.gz: 8146d9b66bb87e84b2179507fb9144012676be726dd5f4312da2482a047e46429a6d41d5b1d49097724aa8cfd68519be06e6e8f860e97f0cbc187de0c20242ca
|
data/bin/cddl
CHANGED
@@ -29,7 +29,10 @@ def read_arg(arg, remember_fn = true)
|
|
29
29
|
else
|
30
30
|
usage unless arg
|
31
31
|
$fn = arg if remember_fn
|
32
|
-
File.read(arg, mode: "rb")
|
32
|
+
File.read(arg, mode: "rb").force_encoding(Encoding::UTF_8).scrub { |c|
|
33
|
+
warn "*** replaced invalid UTF-8 byte sequence #{c.inspect} by U+FFFD REPLACEMENT CHARACTER"
|
34
|
+
0xFFFD.chr(Encoding::UTF_8)
|
35
|
+
}
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
data/cddl.gemspec
CHANGED
data/data/cddl.abnf
CHANGED
@@ -70,27 +70,39 @@ fraction = 1*DIGIT
|
|
70
70
|
exponent = int
|
71
71
|
|
72
72
|
text = %x22 *SCHAR %x22
|
73
|
-
SCHAR = %x20-21 / %x23-7E / SESC
|
74
|
-
|
73
|
+
SCHAR = %x20-21 / %x23-5B / %x5D-7E / NONASCII / SESC
|
74
|
+
|
75
|
+
SESC = "\" ( %x22 / "/" / "\" / ; \" \/ \\
|
76
|
+
%x62 / %x66 / %x6E / %x72 / %x74 / ; \b \f \n \r \t
|
77
|
+
(%x75 hexchar) ) ; \uXXXX
|
78
|
+
|
79
|
+
hexchar = "{" (1*"0" [ hexscalar ] / hexscalar) "}" /
|
80
|
+
non-surrogate / (high-surrogate "\" %x75 low-surrogate)
|
81
|
+
non-surrogate = ((DIGIT / "A"/"B"/"C" / "E"/"F") HEXDIG HEXDIG HEXDIG) /
|
82
|
+
("D" %x30-37 HEXDIG HEXDIG)
|
83
|
+
high-surrogate = "D" ("8"/"9"/"A"/"B") HEXDIG HEXDIG
|
84
|
+
low-surrogate = "D" ("C"/"D"/"E"/"F") HEXDIG HEXDIG
|
85
|
+
hexscalar = "10" HEXDIG HEXDIG HEXDIG HEXDIG / HEXDIG1 HEXDIG HEXDIG HEXDIG HEXDIG
|
86
|
+
/ non-surrogate / HEXDIG [HEXDIG [HEXDIG]]
|
75
87
|
|
76
88
|
bytes = [bsqual] %x27 *BCHAR %x27
|
77
|
-
BCHAR = %x20-26 / %x28-5B / %x5D-7E / SESC / CRLF
|
78
|
-
bsqual =
|
79
|
-
/ %x62.36.34 ; "b64"
|
89
|
+
BCHAR = %x20-26 / %x28-5B / %x5D-7E / NONASCII / SESC / "\'" / CRLF
|
90
|
+
bsqual = "h" / "b64"
|
80
91
|
|
81
92
|
id = EALPHA *(*("-" / ".") (EALPHA / DIGIT))
|
82
93
|
ALPHA = %x41-5A / %x61-7A
|
83
|
-
EALPHA =
|
94
|
+
EALPHA = ALPHA / "@" / "_" / "$"
|
84
95
|
DIGIT = %x30-39
|
85
96
|
DIGIT1 = %x31-39
|
86
97
|
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
98
|
+
HEXDIG1 = DIGIT1 / "A" / "B" / "C" / "D" / "E" / "F"
|
87
99
|
BINDIG = %x30-31
|
88
100
|
|
89
101
|
S = *WS
|
90
102
|
WS = SP / NL
|
91
103
|
SP = %x20
|
92
104
|
NL = COMMENT / CRLF
|
93
|
-
COMMENT = ";" *
|
94
|
-
|
105
|
+
COMMENT = ";" *PCHAR CRLF
|
106
|
+
PCHAR = %x20-7E / NONASCII
|
107
|
+
NONASCII = %xA0-D7FF / %xE000-10FFFD
|
95
108
|
CRLF = %x0A / %x0D.0A
|
96
|
-
|
data/lib/cddl.rb
CHANGED
@@ -61,7 +61,7 @@ module CDDL
|
|
61
61
|
if upto - presult < 100
|
62
62
|
part2 = source_text[presult...upto]
|
63
63
|
else
|
64
|
-
part2 = source_text[presult, 50] + "......." + source_text[upto-50, 50]
|
64
|
+
part2 = source_text[presult, 50] + "......." + (source_text[upto-50, 50] || "")
|
65
65
|
end
|
66
66
|
warn "*** Look for syntax problems around the #{
|
67
67
|
"%%%".colorize(background: :light_yellow)} markers:\n#{
|
@@ -1473,6 +1473,18 @@ module CDDL
|
|
1473
1473
|
end
|
1474
1474
|
end
|
1475
1475
|
|
1476
|
+
STRING_ESCAPES = {
|
1477
|
+
"\"" => "\"",
|
1478
|
+
"/" => "/",
|
1479
|
+
"\\" => "\\",
|
1480
|
+
"'" => "'",
|
1481
|
+
"b" => "\b",
|
1482
|
+
"f" => "\f",
|
1483
|
+
"n" => "\n",
|
1484
|
+
"r" => "\r",
|
1485
|
+
"t" => "\t",
|
1486
|
+
}
|
1487
|
+
|
1476
1488
|
def value(n)
|
1477
1489
|
# cheat:
|
1478
1490
|
# warn n
|
@@ -1482,7 +1494,20 @@ module CDDL
|
|
1482
1494
|
if parts[-1] != ""
|
1483
1495
|
warn "*** Problem decoding byte string #{s.inspect}"
|
1484
1496
|
end
|
1485
|
-
bsval = parts[0...-1].join("'").gsub(/\\(
|
1497
|
+
bsval = parts[0...-1].join("'").gsub(/\\u([Dd][89AaBb][0-9a-zA-Z]{2})\\u([Dd][CcDdEeFf][0-9a-zA-Z]{2})|\\u([0-9a-zA-Z]{4})|\\u\{([0-9a-zA-Z]+)\}|\r?(\n)|\\([^u])/) {
|
1498
|
+
if hex = $3 || $4
|
1499
|
+
hex.to_i(16).chr(Encoding::UTF_8)
|
1500
|
+
elsif lf = $5
|
1501
|
+
lf
|
1502
|
+
elsif escaped = $6
|
1503
|
+
STRING_ESCAPES[$6] or (
|
1504
|
+
fail "Invalid String Escape #{escaped.inspect} in #{s.inspect}"
|
1505
|
+
)
|
1506
|
+
else
|
1507
|
+
((($1.to_i(16) & 0x3ff) << 10) +
|
1508
|
+
($2.to_i(16) & 0x3ff) + 0x10000).chr(Encoding::UTF_8)
|
1509
|
+
end
|
1510
|
+
}
|
1486
1511
|
[:bytes,
|
1487
1512
|
case bsqual
|
1488
1513
|
when ""
|
@@ -1496,7 +1521,17 @@ module CDDL
|
|
1496
1521
|
end
|
1497
1522
|
]
|
1498
1523
|
else
|
1499
|
-
|
1524
|
+
if s[-1] == '"'
|
1525
|
+
s.gsub!(/\\u([Dd][89AaBb][0-9a-zA-Z]{2})\\u([Dd][CcDdEeFf][0-9a-zA-Z]{2})|\\([^u]|u[0-9a-zA-Z]{4})/) {
|
1526
|
+
if $3
|
1527
|
+
"\\#$3" # skip this, use eval parser
|
1528
|
+
else
|
1529
|
+
((($1.to_i(16) & 0x3ff) << 10) +
|
1530
|
+
($2.to_i(16) & 0x3ff) + 0x10000).chr(Encoding::UTF_8)
|
1531
|
+
end
|
1532
|
+
}
|
1533
|
+
end
|
1534
|
+
val = eval(s)
|
1500
1535
|
# warn val
|
1501
1536
|
case val
|
1502
1537
|
when Integer; [:int, val]
|
data/test-data/b64u-strict.cddl
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cbor-diag
|
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: '0'
|
292
292
|
requirements: []
|
293
|
-
rubygems_version: 3.5.
|
293
|
+
rubygems_version: 3.5.9
|
294
294
|
signing_key:
|
295
295
|
specification_version: 4
|
296
296
|
summary: CDDL generator and validator.
|