speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
292 stars 36 forks source link

wrong SHA512 and contents for attachment #446

Closed pr-apes closed 1 year ago

pr-apes commented 1 year ago

@pgundlach,

attaching https://raw.githubusercontent.com/speedata/boxesandglue-examples/main/simpletable/result.pdf with the following source (and sp --dummy):

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">
  <PDFOptions displaymode="attachments"/>
  <AttachFile filename="result.pdf" name="{sd:sha512(doc('result.pdf'))}" type="application/pdf" description="abc"/>

  <Record element="data">
    <PlaceObject>
      <Textblock>
        <Paragraph>
          <Value select="sd:sha512(doc('result.pdf'))"/>
        </Paragraph>
      </Textblock>
    </PlaceObject>
  </Record>
</Layout>

Gives the following SHA512:

e7904f654135c5d4bf1ec96225a09106e485e0cb0e2cc39460b4e793cb18799a8a03b95268254dfd5d0d2dd0f9a35c42f39e36d3bdd9f9b63ddb2e0479237c55.pdf

Also the saved attachment has the same SHA512. But the attachment contents are broken.

In fact, the SHA512 for https://raw.githubusercontent.com/speedata/boxesandglue-examples/main/simpletable/result.pdf should read:

11d79e0250c820300a10e1e5e0d1f11ef3d0e2e36f6d81d43c18c70115455ef3c44e3d937b565f2d31101b132b3cd1338f1360960fecf6aecd8284c91f9eaff6

I don't know what is wrong here.

As far as I can remember, SHA512 for external documents worked fine before.

Many thanks for your help.

pr-apes commented 1 year ago

@pgundlach,

with the following layout.txt file and invoking sp --dummy --layout=layout.txt, both embedding and SHA512 are fine (SHA512 reads 71f41f7b8fc1e8adfe1a974e711033f2a6570e324788cf16e7f0ed64c6bcd6196536d30ee1daacc97dd9100c3518fbaef23cacaead6b6fda17500e05feba7ac0).

Also alayout.xml.zip (which is a pure XML file, but I had to add the .zip extension to attach it here) is embedded fine and SHA512 is OK (which reads 2d19943126e2f1378f27a4b0755ed140a23f95181028a04c6706de661d92b2f7ae2ebecf5e203a065ecc8828abd09b9ca0d5fec513b471866e5e8bb5da68ded7).

So, I guess that LuaTeX may be reading these files in plain text (which was fine for XML files), but not in binary mode (which may be required for PDF files).

Just in case it might help.

pgundlach commented 1 year ago

I cannot reproduce the problem on my mac, but perhaps I have fixed it. Can you try the new version 4.13.3?

pr-apes commented 1 year ago

Many thanks for the fix, @pgundlach.

I think #448 is also required to fix SHA functions of external files (doc function from XPath).

At least, after fixing this, SHA512 is right on my computer.