Commit 752f43d4e4fc6348db63d17b1984116493cc5b2f

Authored by Jay Berkenbilt
1 parent 62d47bff

Allow empty b: binary JSON strings

libqpdf/QPDF_json.cc
... ... @@ -128,7 +128,7 @@ is_binary_string(std::string const& v, std::string& str)
128 128 }
129 129 ++count;
130 130 }
131   - return ((count > 0) && (count % 2 == 0));
  131 + return (count % 2 == 0);
132 132 }
133 133 return false;
134 134 }
... ... @@ -180,10 +180,10 @@ QPDF::test_json_validators()
180 180 check(str == "");
181 181 check(!is_binary_string("", str));
182 182 check(!is_binary_string("x:", str));
183   - check(!is_binary_string("b:", str));
184 183 check(!is_binary_string("b:1", str));
185 184 check(!is_binary_string("b:123", str));
186 185 check(!is_binary_string("b:gh", str));
  186 + check(is_binary_string("b:", str));
187 187 check(is_binary_string("b:12", str));
188 188 check(is_binary_string("b:123aBC", str));
189 189 check(!is_name(""));
... ...
qpdf/qtest/qpdf/manual-qpdf-json-out.json
... ... @@ -94,6 +94,7 @@
94 94 "u:one",
95 95 "b:24a2",
96 96 "u:",
  97 + "u:",
97 98 "u:()",
98 99 "u:(",
99 100 "u:)",
... ...
qpdf/qtest/qpdf/manual-qpdf-json-pdf.json
... ... @@ -45,6 +45,7 @@
45 45 "u:one",
46 46 "b:24a2",
47 47 "u:",
  48 + "u:",
48 49 "u:()",
49 50 "u:(",
50 51 "u:)",
... ...
qpdf/qtest/qpdf/manual-qpdf-json.json
... ... @@ -117,6 +117,7 @@
117 117 "/strings": [
118 118 "u:one",
119 119 "b:24a2",
  120 + "b:",
120 121 "u:",
121 122 "u:()",
122 123 "u:(",
... ...
qpdf/qtest/qpdf/manual-qpdf-json.pdf
... ... @@ -47,6 +47,7 @@ endobj
47 47 (one)
48 48 <24a2>
49 49 ()
  50 + ()
50 51 (\(\))
51 52 (\()
52 53 (\))
... ... @@ -163,14 +164,14 @@ xref
163 164 0000000000 65535 f
164 165 0000000052 00000 n
165 166 0000000133 00000 n
166   -0000000829 00000 n
167   -0000000928 00000 n
168   -0000001029 00000 n
169   -0000001251 00000 n
170   -0000001322 00000 n
171   -0000001421 00000 n
172   -0000001467 00000 n
173   -0000001612 00000 n
  167 +0000000836 00000 n
  168 +0000000935 00000 n
  169 +0000001036 00000 n
  170 +0000001258 00000 n
  171 +0000001329 00000 n
  172 +0000001428 00000 n
  173 +0000001474 00000 n
  174 +0000001619 00000 n
174 175 trailer <<
175 176 /QTest 2 0 R
176 177 /Root 1 0 R
... ... @@ -178,5 +179,5 @@ trailer &lt;&lt;
178 179 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
179 180 >>
180 181 startxref
181   -1648
  182 +1655
182 183 %%EOF
... ...