whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] 01/01: switch to the pip3 version of img2pdf
Date Wed, 31 Oct 2018 12:57:58 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch pip3-img2pdf
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit abf9b3c12b47f26933bb2cb1c0bdd43e560053b7
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Wed Oct 31 08:56:15 2018 -0400

    switch to the pip3 version of img2pdf
---
 www/secretary/workbench/img2pdf              | 7 +++++++
 www/secretary/workbench/models/attachment.rb | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/www/secretary/workbench/img2pdf b/www/secretary/workbench/img2pdf
new file mode 100755
index 0000000..fe48b71
--- /dev/null
+++ b/www/secretary/workbench/img2pdf
@@ -0,0 +1,7 @@
+#!/usr/bin/python3
+
+# Alternate executable wrapper for img2pdf, created because the packaged
+# version of img2pdf on Ubuntu 16.04 contains a back-level version
+
+import img2pdf
+img2pdf.main()
diff --git a/www/secretary/workbench/models/attachment.rb b/www/secretary/workbench/models/attachment.rb
index edeea31..b95771b 100644
--- a/www/secretary/workbench/models/attachment.rb
+++ b/www/secretary/workbench/models/attachment.rb
@@ -61,7 +61,8 @@ class Attachment
 
     if IMAGE_TYPES.include? ext or content_type.start_with? 'image/'
       pdf = SafeTempFile.new([safe_name, '.pdf'])
-      system 'img2pdf', '--output', pdf.path, file.path
+      img2pdf = File.expand_path('../img2pdf', __dir__.untaint).untaint
+      system img2pdf, '--output', pdf.path, file.path
       file.unlink
       return pdf
     end


Mime
View raw message