Commit bf477fbb9622b85caeafc0783381de7103b281cd

Authored by Jay Berkenbilt
Committed by Jay Berkenbilt
1 parent 2611f42c

Do double indirect test correctly

qpdf/qtest/qpdf/parse-object.out
1 [ /name 16059 3.14159 false << /key true /other [ (string1) (string2) ] >> null ] 1 [ /name 16059 3.14159 false << /key true /other [ (string1) (string2) ] >> null ]
2 logic error parsing indirect: QPDFObjectHandle::parse called without context on an object with indirect references 2 logic error parsing indirect: QPDFObjectHandle::parse called without context on an object with indirect references
3 trailing data: parsed object (trailing test): trailing data found parsing object from string 3 trailing data: parsed object (trailing test): trailing data found parsing object from string
4 -broken indirect object reference: parsed object: trailing data found parsing object from string 4 +WARNING: parsed object (offset 9): unknown token while reading object; treating as string
5 test 31 done 5 test 31 done
qpdf/test_driver.cc
@@ -1245,14 +1245,13 @@ test_31(QPDF&amp; pdf, char const* arg2) @@ -1245,14 +1245,13 @@ test_31(QPDF&amp; pdf, char const* arg2)
1245 } catch (std::runtime_error const& e) { 1245 } catch (std::runtime_error const& e) {
1246 std::cout << "trailing data: " << e.what() << std::endl; 1246 std::cout << "trailing data: " << e.what() << std::endl;
1247 } 1247 }
1248 - try {  
1249 - assert(QPDFObjectHandle::parse(&pdf, "5 0 R").isInteger());  
1250 - QPDFObjectHandle::parse(&pdf, "5 0 R 0 R");  
1251 - std::cout << "oops -- didn't throw" << std::endl;  
1252 - } catch (std::runtime_error const& e) {  
1253 - std::cout << "broken indirect object reference: " << e.what()  
1254 - << std::endl;  
1255 - } 1248 + assert(
  1249 + QPDFObjectHandle::parse(&pdf, "[5 0 R]").getArrayItem(0).isInteger());
  1250 + // Make sure an indirect integer followed by "0 R" is not
  1251 + // mistakenly parsed as an indirect object.
  1252 + assert(
  1253 + QPDFObjectHandle::parse(&pdf, "[5 0 R 0 R /X]").unparse() ==
  1254 + "[ 5 0 R 0 (R) /X ]");
1256 assert( 1255 assert(
1257 QPDFObjectHandle::parse(&pdf, "[1 0 R]", "indirect test").unparse() == 1256 QPDFObjectHandle::parse(&pdf, "[1 0 R]", "indirect test").unparse() ==
1258 "[ 1 0 R ]"); 1257 "[ 1 0 R ]");