From a1e1e72375c6b8f511c779c74b3dd1073afff6c1 Mon Sep 17 00:00:00 2001 From: Warren Guy Date: Sat, 30 Jan 2016 18:30:51 +0800 Subject: Generate valid Message-ID in email rejection mailer Use a Message-ID that is RFC 2111 compliant. This fix is consistent with how the Message-ID is generated in the 'notify' mailer. --- app/mailers/email_rejection_mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/mailers/email_rejection_mailer.rb b/app/mailers/email_rejection_mailer.rb index 883f1c73ad4..76db31a4c45 100644 --- a/app/mailers/email_rejection_mailer.rb +++ b/app/mailers/email_rejection_mailer.rb @@ -10,7 +10,7 @@ class EmailRejectionMailer < BaseMailer subject: "[Rejected] #{@original_message.subject}" } - headers['Message-ID'] = SecureRandom.hex + headers['Message-ID'] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>" headers['In-Reply-To'] = @original_message.message_id headers['References'] = @original_message.message_id -- cgit v1.2.1 From 99492d6b8d01f8ec0e5c391532e364d06dbd41b4 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 27 Jan 2016 14:09:58 +0100 Subject: Optimize fetching issues closed by a merge request Instead of running ClosingIssueExtractor for every commit in a merge request we can gather all the commit messages (and the merge request description), concatenate all this together and then run ClosingIssueExtractor only once. The result of this is that MergeRequest#closes_issues is now between 3.5x and 4x faster than the old setup. Using a merge request with 10 commits (each referencing a number of issues to close) this reduced the call duration from around 200 milliseconds to around 50 milliseconds. As a result of these changes the Jira related tests for MergeRequest#closes_issues have been removed. These tests stubbed Commit#closes_issues meaning that the only code that was really tested was the call to Array#uniq to filter out duplicate issues. As this code is no longer used (nor present) the corresponding tests were removed. Related: gitlab-org/gitlab-ce#12419 --- app/models/merge_request.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 41dd248d80a..09af60a2016 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -346,10 +346,10 @@ class MergeRequest < ActiveRecord::Base # Return the set of issues that will be closed if this merge request is accepted. def closes_issues(current_user = self.author) if target_branch == project.default_branch - issues = commits.flat_map { |c| c.closes_issues(current_user) } - issues.push(*Gitlab::ClosingIssueExtractor.new(project, current_user). - closed_by_message(description)) - issues.uniq(&:id) + messages = commits.map(&:safe_message) << description + + Gitlab::ClosingIssueExtractor.new(project, current_user). + closed_by_message(messages.join("\n")) else [] end -- cgit v1.2.1 From f86ddfd36538667cd0c484a62825569a36ef2a2c Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 12 Sep 2015 20:54:06 -0700 Subject: Render sanitized SVG images Closes https://github.com/gitlabhq/gitlabhq/issues/9265 --- app/helpers/blob_helper.rb | 12 ++++++++++++ app/views/projects/blob/_blob.html.haml | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 694c03206bd..16967927922 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -126,4 +126,16 @@ module BlobHelper blob.size end end + + def blob_svg?(blob) + blob.language && blob.language.name == 'SVG' + end + + # SVGs can contain malicious JavaScript; only include whitelisted + # elements and attributes. Note that this whitelist is by no means complete + # and may omit some elements. + def sanitize_svg(blob) + blob.data = Loofah.scrub_fragment(blob.data, :strip).to_xml + blob + end end diff --git a/app/views/projects/blob/_blob.html.haml b/app/views/projects/blob/_blob.html.haml index 3d8d88834e2..2c5b8dc4356 100644 --- a/app/views/projects/blob/_blob.html.haml +++ b/app/views/projects/blob/_blob.html.haml @@ -35,7 +35,10 @@ - if blob.lfs_pointer? = render "download", blob: blob - elsif blob.text? - = render "text", blob: blob + - if blob_svg?(blob) + = render "image", blob: sanitize_svg(blob) + - else + = render "text", blob: blob - elsif blob.image? = render "image", blob: blob - else -- cgit v1.2.1 From 933834c4a60610710fc949daa2e15531c2c45780 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 1 Feb 2016 16:55:00 -0500 Subject: Allow manual resize of js-autosize textareas First, the autosize library was being too controlling and removed the `resize` property from any elements to which it was attached, removing the drag handle. Second, we detect when the user manually resizes an autosize textarea, and then remove the autosize behavior from it and increase its max-height. This should allow for the best of both worlds. Closes #12832 --- app/assets/javascripts/behaviors/autosize.js.coffee | 20 +++++++++++++++++++- app/assets/stylesheets/framework/markdown_area.scss | 2 +- app/assets/stylesheets/pages/note_form.scss | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/behaviors/autosize.js.coffee b/app/assets/javascripts/behaviors/autosize.js.coffee index b32072e61ee..a072fe48a98 100644 --- a/app/assets/javascripts/behaviors/autosize.js.coffee +++ b/app/assets/javascripts/behaviors/autosize.js.coffee @@ -1,4 +1,22 @@ +#= require jquery.ba-resize #= require autosize $ -> - autosize($('.js-autosize')) + $fields = $('.js-autosize') + + $fields.on 'autosize:resized', -> + $field = $(@) + $field.data('height', $field.outerHeight()) + + $fields.on 'resize.autosize', -> + $field = $(@) + + if $field.data('height') != $field.outerHeight() + $field.data('height', $field.outerHeight()) + autosize.destroy($field) + $field.css('max-height', window.outerHeight) + + autosize($fields) + autosize.update($fields) + + $fields.css('resize', 'vertical') diff --git a/app/assets/stylesheets/framework/markdown_area.scss b/app/assets/stylesheets/framework/markdown_area.scss index 6732343802a..1d8611b04dc 100644 --- a/app/assets/stylesheets/framework/markdown_area.scss +++ b/app/assets/stylesheets/framework/markdown_area.scss @@ -83,7 +83,7 @@ background: #FFF; border: 1px solid #ddd; min-height: 140px; - max-height: 430px; + max-height: 500px; padding: 5px; box-shadow: none; width: 100%; diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index 32ba1676333..158c2a47862 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -147,7 +147,7 @@ .edit_note { .markdown-area { min-height: 140px; - max-height: 430px; + max-height: 500px; } .note-form-actions { background: transparent; -- cgit v1.2.1