[latex3-commits] [git/LaTeX3-latex3-l3build] master: Normalise out PDF binary streams (407f257)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Aug 2 16:30:06 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/407f25790ca6612dd2c9c36c905f9d070cb094e3

>---------------------------------------------------------------

commit 407f25790ca6612dd2c9c36c905f9d070cb094e3
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Aug 2 15:30:06 2018 +0100

    Normalise out PDF binary streams
    
    This will avoid any binary streams leaking out, including those
    generated by LuaTeX (which is much more keen to make them).


>---------------------------------------------------------------

407f25790ca6612dd2c9c36c905f9d070cb094e3
 l3build-check.lua       |   35 ++++++++++++++++++++++++----------
 testfiles/00-test-2.tpf |   48 +++--------------------------------------------
 2 files changed, 28 insertions(+), 55 deletions(-)

diff --git a/l3build-check.lua b/l3build-check.lua
index f9c9910..c84f3b2 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -491,24 +491,39 @@ local function normalise_pdf(pdffile,npdffile)
   local file = assert(open(pdffile, "rb"))
   local contents = gsub(file:read("*all") .. "\n", "\r\n", "\n")
   close(file)
-  local newcontent = ""
-  local skip = false
+  local new_content = ""
+  local stream_content = ""
+  local stream = false
   for line in gmatch(contents, "([^\n]*)\n") do
-    if skip then
+    if stream then
       if match(line,"endstream") then
-        skip = false
-        line = ""
+        stream = false
+        local binary = false
+        for i = 0, 31 do
+          if match(stream_content,char(i)) then
+            binary = true
+            break
+          end
+        end
+        if binary then
+          new_content = new_content .. "[BINARY STREAM]\n"
+        else
+          new_content = new_content .. stream_content
+        end
+      else
+        stream_content = stream_content .. line
       end
-    elseif match(line,"currentfile eexec") then
-      skip = true
+    elseif match(line,"^stream$") then
+      stream = true
+      stream_content = ""
     end
-    if not match(line, "^ *$") and not skip then
-      newcontent = newcontent .. line .. os_newline
+    if not match(line, "^ *$") and not stream then
+      new_content = new_content .. line .. os_newline
     end
   end
   local newfile = open(npdffile, "w")
   output(newfile)
-  write(newcontent)
+  write(new_content)
   close(newfile)
 end
 
diff --git a/testfiles/00-test-2.tpf b/testfiles/00-test-2.tpf
index 2eecdb4..a9ffe7b 100644
--- a/testfiles/00-test-2.tpf
+++ b/testfiles/00-test-2.tpf
@@ -4,11 +4,7 @@
 <<
 /Length 73        
 >>
-stream
-BT
-/F15 9.9626 Tf 92.921 759.927 Td [(#$%&)]TJ 0 -23.91 Td [(#$%&)]TJ
-ET
-endstream
+BT/F15 9.9626 Tf 92.921 759.927 Td [(#$%&)]TJ 0 -23.91 Td [(#$%&)]TJETendstream
 endobj
 2 0 obj
 <<
@@ -35,46 +31,8 @@ endobj
 /Length3 0
 /Length 8480      
 >>
-stream
-%!PS-AdobeFont-1.0: CMTT10 003.002
-%%Title: CMTT10
-%Version: 003.002
-%%CreationDate: Mon Jul 13 16:17:00 2009
-%%Creator: David M. Jones
-%Copyright: Copyright (c) 1997, 2009 American Mathematical Society
-%Copyright: (<http://www.ams.org>), with Reserved Font Name CMTT10.
-% This Font Software is licensed under the SIL Open Font License, Version 1.1.
-% This license is in the accompanying file OFL.txt, and is also
-% available with a FAQ at: http://scripts.sil.org/OFL.
-%%EndComments
-FontDirectory/CMTT10 known{/CMTT10 findfont dup/UniqueID known{dup
-/UniqueID get 5000832 eq exch/FontType get 1 eq and}{pop false}ifelse
-{save true}{false}ifelse}{false}ifelse
-11 dict begin
-/FontType 1 def
-/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def
-/FontName /TZCMOM+CMTT10 def
-/FontBBox {-4 -233 537 696 }readonly def
-/PaintType 0 def
-/FontInfo 9 dict dup begin
-/version (003.002) readonly def
-/Notice (Copyright \050c\051 1997, 2009 American Mathematical Society \050<http://www.ams.org>\051, with Reserved Font Name CMTT10.) readonly def
-/FullName (CMTT10) readonly def
-/FamilyName (Computer Modern) readonly def
-/Weight (Medium) readonly def
-/ItalicAngle 0 def
-/isFixedPitch true def
-/UnderlinePosition -100 def
-/UnderlineThickness 50 def
-end readonly def
-/Encoding 256 array
-0 1 255 {1 index exch /.notdef put} for
-dup 38 /ampersand put
-dup 36 /dollar put
-dup 35 /numbersign put
-dup 37 /percent put
-readonly def
-currentdict end
+[BINARY STREAM]
+endstream
 endobj
 8 0 obj
 <<





More information about the latex3-commits mailing list