Source: gdcm Version: 3.0.24-11 Severity: normal Tags: ftbfs patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Dear Maintainer, gdcm fails to build against poppler >= 26.02 (26.07.0 should be available in experimental soon). Two poppler API changes break the build: * poppler 26.02 changed the PDFDoc stream constructor to take std::unique_ptr<BaseStream>. This also breaks the LIBPOPPLER_PDFDOC_HAS_OPTIONAL configure probe (it tested the removed raw-pointer variant), so gdcminfo.cxx and gdcmpdf.cxx silently fall back to even older, long-removed poppler APIs * poppler 26.04 changed Object::getString() to return const std::string& instead of const GooString* ``` Applications/Cxx/gdcminfo.cxx:207:34: error: cannot convert 'const std::string' to 'const GooString*' in initialization Applications/Cxx/gdcminfo.cxx:517:51: error: no matching function for call to 'PDFDoc::PDFDoc(MemStream*&, GooString*&, GooString*&)' ``` The attached patch re-tests the optional-passwords probe via PDFDocFactory, adds compile probes for the two new APIs, and adds code branches for them. Everything follows the existing compile-probe convention, so the patch is a no-op with the current poppler (26.01) and is safe to apply now, ahead of the transition. Thanks, Nadzeya -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEuVOE/FJ0HcdfWSw//lAdKwFeZPsFAmpiJaAACgkQ/lAdKwFe ZPuPTg//QPojsqkd71zylZOCHowAbVBQmsoQ32Dd+z7YU6ImhBmf294EEkNuhj2B Wx0zRGIBS+UI6gZ17wO+CJjVSuPfhkXhamiaYRsU5BFTUHQwzF7AzUF24ZkubmGh Ms9ctesVkLFjHa4lrSb3UlcY9MeqQLaUSBV2K3p/63WWlUGMOaQGW9EV19DZx3sE CU2Mo/c2nD4HcScsJSvhgkVnwkPKLOO97Wpdl+H3kHrZKkOg8R5/HcelwgyQMHn9 KfuPfNqi4bRdvn3OOyt1IN+DfL2N6slY5FsF2IoaHTVCcnRKIBugBUoGZXTVQ6P/ RucB6qme+ftgalhbbTbLcwhMXmBW1o3mYqa9Ok6P2JVeYg5GILUQZpNOyqxfWJEw 5JoriUsxFvCkFvYYekcx3ixp2NLek/A5xkOLXW7cHUWaVao8I4V+LcqAd+FfZmso c3T6gsyWZcvBIF781NoMEwvy+Y4n6sWYvFwSJG8N6Nas/gI5PKwf1rg7hMPSXDLS OpdQ9DSBXnriCuMlPxqP8O5zD5NRaDgITRIsPIt+/XMaXdQGYs/vVuZv01zkxKoF iTgtfhc+jIUWV3GUyy5FU3vTpzoJCp6rh98zJ2C9kyBEvLB/fhYwtICVBk0Hq+ji ZdmgN0J1VUifoS+2EB6BEQ99w49z5S8CT2H7yYXRKZkwF7lXZA8= =r62O -----END PGP SIGNATURE-----
Description: Fix FTBFS with poppler >= 26.02 Three poppler API changes break the build: 26.02 made the PDFDoc stream constructor take std::unique_ptr<BaseStream>, which also breaks the LIBPOPPLER_PDFDOC_HAS_OPTIONAL configure probe (it tested the removed raw pointer variant), and 26.04 changed Object::getString() to return const std::string& instead of const GooString* . Re-test the optional-passwords probe via PDFDocFactory, add probes for the two new APIs, and add code branches for them. All checks are compile-probe-based, so older poppler still builds Author: Nadzeya Hutsko <[email protected]> Bug-Ubuntu: https://bugs.launchpad.net/bugs/2161630 Forwarded: no Last-Update: 2026-07-23 --- a/Applications/Cxx/CMakeLists.txt +++ b/Applications/Cxx/CMakeLists.txt @@ -117,12 +117,24 @@ list(APPEND libpoppler_flags -DLIBPOPPLER_UNICODEMAP_HAS_CONSTMAPUNICODE) endif() CHECK_CXX_SOURCE_COMPILES( - "\#include <poppler/PDFDoc.h>\nint main() { std::optional<GooString> ownerPW, userPW; PDFDoc d((BaseStream*)nullptr,ownerPW,userPW); return 0;}" + "\#include <poppler/PDFDocFactory.h>\nint main() { std::optional<GooString> ownerPW, userPW; GooString fileName; PDFDocFactory().createPDFDoc(fileName,ownerPW,userPW); return 0;}" LIBPOPPLER_PDFDOC_HAS_OPTIONAL) if(LIBPOPPLER_PDFDOC_HAS_OPTIONAL) list(APPEND libpoppler_flags -DLIBPOPPLER_PDFDOC_HAS_OPTIONAL) endif() CHECK_CXX_SOURCE_COMPILES( + "\#include <poppler/PDFDoc.h>\nint main() { std::optional<GooString> ownerPW, userPW; PDFDoc d(std::unique_ptr<BaseStream>{},ownerPW,userPW); return 0;}" + LIBPOPPLER_PDFDOC_HAS_UNIQUEPTR_STREAM) + if(LIBPOPPLER_PDFDOC_HAS_UNIQUEPTR_STREAM) + list(APPEND libpoppler_flags -DLIBPOPPLER_PDFDOC_HAS_UNIQUEPTR_STREAM) + endif() + CHECK_CXX_SOURCE_COMPILES( + "\#include <poppler/Object.h>\nint main() { Object o; const std::string &s = o.getString(); (void)s; return 0; }" + LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING) + if(LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING) + list(APPEND libpoppler_flags -DLIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING) + endif() + CHECK_CXX_SOURCE_COMPILES( "\#include <poppler/goo/GooString.h>\nint main() { GooString gs; gs.size(); return 0; }" LIBPOPPLER_GOOSTRING_HAS_SIZE) if(LIBPOPPLER_GOOSTRING_HAS_SIZE) --- a/Applications/Cxx/gdcminfo.cxx +++ b/Applications/Cxx/gdcminfo.cxx @@ -201,6 +201,9 @@ if (infoDict->lookup((char*)key, &obj)->isString()) #endif { +#ifdef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING + s = obj.getString().c_str(); +#else #ifndef LIBPOPPLER_GOOSTRING_HAS_GETCSTRING const #endif @@ -210,6 +213,7 @@ #else s = gs->c_str(); #endif +#endif if (s[0] == 'D' && s[1] == ':') { s += 2; @@ -268,11 +272,13 @@ #endif { Object obj; +#ifndef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING #ifdef LIBPOPPLER_GOOSTRING_HAS_CONSTGETCHAR const GooString *s1; #else GooString *s1; #endif +#endif bool isUnicode; Unicode u; char buf[8]; @@ -285,6 +291,37 @@ if (infoDict->lookup((char*)key, &obj)->isString()) #endif { +#ifdef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING + const std::string &s1 = obj.getString(); + if ((s1[0] & 0xff) == 0xfe && + (s1[1] & 0xff) == 0xff) + { + isUnicode = true; + i = 2; + } + else + { + isUnicode = false; + i = 0; + } + while (i < (int)s1.size()) + { + if (isUnicode) + { + u = ((s1[i] & 0xff) << 8) | + (s1[i+1] & 0xff); + i += 2; + } + else + { + u = pdfDocEncoding[s1[i] & 0xff]; + ++i; + } + n = uMap->mapUnicode(u, buf, sizeof(buf)); + //fwrite(buf,1,n,stdout); + out.append( std::string(buf, n) ); + } +#else s1 = obj.getString(); if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) @@ -318,6 +355,7 @@ //fwrite(buf,1,n,stdout); out.append( std::string(buf, n) ); } +#endif } #ifndef LIBPOPPLER_NEW_OBJECT_API obj.free(); @@ -514,7 +552,11 @@ #endif PDFDoc *doc; +#ifdef LIBPOPPLER_PDFDOC_HAS_UNIQUEPTR_STREAM + doc = new PDFDoc(std::unique_ptr<BaseStream>(appearStream), ownerPW, userPW); +#else doc = new PDFDoc(appearStream, ownerPW, userPW); +#endif std::string title; std::string subject; --- a/Applications/Cxx/gdcmpdf.cxx +++ b/Applications/Cxx/gdcmpdf.cxx @@ -52,6 +52,9 @@ if (infoDict->lookup((char*)key, &obj)->isString()) #endif { +#ifdef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING + s = obj.getString().c_str(); +#else #ifndef LIBPOPPLER_GOOSTRING_HAS_GETCSTRING const #endif @@ -61,6 +64,7 @@ #else s = gs->c_str(); #endif +#endif if (s[0] == 'D' && s[1] == ':') { s += 2; @@ -119,11 +123,13 @@ #endif { Object obj; +#ifndef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING #ifdef LIBPOPPLER_GOOSTRING_HAS_CONSTGETCHAR const GooString *s1; #else GooString *s1; #endif +#endif bool isUnicode = false; Unicode u; char buf[8]; @@ -136,6 +142,37 @@ if (infoDict->lookup((char*)key, &obj)->isString()) #endif { +#ifdef LIBPOPPLER_OBJECT_GETSTRING_IS_STDSTRING + const std::string &s1 = obj.getString(); + if ((s1[0] & 0xff) == 0xfe && + (s1[1] & 0xff) == 0xff) + { + isUnicode = true; + i = 2; + } + else + { + isUnicode = false; + i = 0; + } + while (i < (int)s1.size()) + { + if (isUnicode) + { + u = ((s1[i] & 0xff) << 8) | + (s1[i+1] & 0xff); + i += 2; + } + else + { + u = pdfDocEncoding[s1[i] & 0xff]; + ++i; + } + n = uMap->mapUnicode(u, buf, sizeof(buf)); + //fwrite(buf,1,n,stdout); + out.append( std::string(buf, n) ); + } +#else s1 = obj.getString(); if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) @@ -169,6 +206,7 @@ //fwrite(buf,1,n,stdout); out.append( std::string(buf, n) ); } +#endif } #ifndef LIBPOPPLER_NEW_OBJECT_API obj.free();

