redmine: Migrate from 3.2 to 3.4

Change-Id: I8bfd387c71477c4dfdea2eb8520415ce129a3b32
This commit is contained in:
Harald Welte 2018-05-30 12:24:32 +00:00
parent da04310dd9
commit 0f0fd8c41e
4 changed files with 2 additions and 144 deletions

View File

@ -1,17 +1,9 @@
FROM redmine:3.2
FROM redmine:3.4
RUN apt-get update && \
apt-get install -y --no-install-recommends \
graphviz \
imagemagick \
mscgen \
patch && \
apt-get clean
COPY redmine-issue-2047-svg-image-support.diff /tmp/redmine-issue-2047-svg-image-support.diff
RUN cd app && patch -p1 < /tmp/redmine-issue-2047-svg-image-support.diff
COPY redmine-openid-hmac-digest.diff /tmp/
RUN cd /usr/local/bundle/gems/ruby-openid-2.3.0 && patch -p0 < /tmp/redmine-openid-hmac-digest.diff
COPY redmine-image-content-disposition.diff /tmp/
RUN patch -p1 < /tmp/redmine-image-content-disposition.diff

View File

@ -1,64 +0,0 @@
From 6c94d485cb3e23559da8f0356a1052a620d7a2c2 Mon Sep 17 00:00:00 2001
From: Harald Welte <laforge@gnumonks.org>
Date: Mon, 14 May 2018 23:16:51 +0200
Subject: [PATCH] chagnge content-disposition of pdf/image/text/patch to
'inline'
Related: https://osmocom.org/issues/3264
---
app/controllers/attachments_controller.rb | 9 ++++++++-
app/models/attachment.rb | 8 ++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index c2b5fa9c8..f2a57c31d 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -57,7 +57,7 @@ class AttachmentsController < ApplicationController
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
- :disposition => 'attachment'
+ :disposition => disposition(@attachment)
end
end
@@ -188,4 +188,12 @@ class AttachmentsController < ApplicationController
end
content_type.to_s
end
+
+ def disposition(attachment)
+ if attachment.is_pdf? || attachment.is_image? || attachment.is_diff? || attachment.is_text?
+ 'inline'
+ else
+ 'attachment'
+ end
+ end
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 3d16f57cc..a2520b0d5 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -236,10 +236,18 @@ class Attachment < ActiveRecord::Base
Redmine::MimeType.is_type?('text', filename)
end
+ def is_image?
+ Redmine::MimeType.is_type?('image', filename)
+ end
+
def is_diff?
self.filename =~ /\.(patch|diff)$/i
end
+ def is_pdf?
+ Redmine::MimeType.of(filename) == "application/pdf"
+ end
+
# Returns true if the file is readable
def readable?
File.readable?(diskfile)
--
2.17.0

View File

@ -1,24 +0,0 @@
diff -ru app.orig/helpers/application_helper.rb app/helpers/application_helper.rb
--- app.orig/helpers/application_helper.rb 2018-01-08 19:37:37.000000000 +0000
+++ app/helpers/application_helper.rb 2018-05-14 08:15:11.558390732 +0000
@@ -637,7 +637,7 @@
attachments = options[:attachments] || []
attachments += obj.attachments if obj.respond_to?(:attachments)
if attachments.present?
- text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
+ text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|svg))"(\s+alt="([^"]*)")?/i) do |m|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
# search for the picture in attachments
if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
diff -ru app.orig/models/attachment.rb app/models/attachment.rb
--- app.orig/models/attachment.rb 2018-01-08 19:37:37.000000000 +0000
+++ app/models/attachment.rb 2018-05-14 08:14:49.542526978 +0000
@@ -193,7 +193,7 @@
end
def image?
- !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i)
+ !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|svg)$/i)
end
def thumbnailable?

View File

@ -1,46 +0,0 @@
diff -Nurd lib/openid/cryptutil.rb
/usr/local/lib/ruby/gems/2.3/gems/ruby-openid-2.3.0/lib/openid/cryptutil.rb
--- lib/openid/cryptutil.rb 1970-01-01 00:00:00.000000000 +0000
+++ /usr/local/lib/ruby/gems/2.3/gems/ruby-openid-2.3.0/lib/openid/cryptutil.rb 2017-07-17
18:25:45.146746571 +0000
@@ -2,7 +2,7 @@
require "digest/sha1"
require "digest/sha2"
begin
- require "digest/hmac"
+ require "openssl"
rescue LoadError
begin
# Try loading the ruby-hmac files if they exist
@@ -33,27 +33,19 @@
end
def CryptUtil.sha1(text)
- return Digest::SHA1.digest(text)
+ return OpenSSL::Digest.new('sha1').digest(text)
end
def CryptUtil.hmac_sha1(key, text)
- if Digest.const_defined? :HMAC
- Digest::HMAC.new(key,Digest::SHA1).update(text).digest
- else
- return HMAC::SHA1.digest(key, text)
- end
+ return OpenSSL::HMAC.digest('sha1', key, text)
end
def CryptUtil.sha256(text)
- return Digest::SHA256.digest(text)
+ return OpenSSL::Digest.new('sha256').digest(text)
end
def CryptUtil.hmac_sha256(key, text)
- if Digest.const_defined? :HMAC
- Digest::HMAC.new(key,Digest::SHA256).update(text).digest
- else
- return HMAC::SHA256.digest(key, text)
- end
+ return OpenSSL::HMAC.digest('sha256', key, text)
end
# Generate a random string of the given length, composed of the