summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-01-15 15:00:58 +0000
committerSean McGivern <sean@gitlab.com>2018-01-16 11:56:07 +0000
commit91939161aace35823f7a60b25647d5e23285c556 (patch)
treee74ab86561ca6f96fc57110712bd967317e7e53b /app
parent82f4564fb7dc57a9a7bb6a052926ee219bb29b13 (diff)
downloadgitlab-ce-91939161aace35823f7a60b25647d5e23285c556.tar.gz
Only highlight search results under the highlighting size limit41666-cannot-search-with-keyword-merge
We should use this limit everywhere, but especially in project search results, where we could be highlighting very long single lines. (Typical examples: minified JavaScript, and JSON data files.)
Diffstat (limited to 'app')
-rw-r--r--app/helpers/blob_helper.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 5e3b2e5581c..a6e1de6ffdc 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -1,6 +1,8 @@
module BlobHelper
def highlight(blob_name, blob_content, repository: nil, plain: false)
+ plain ||= blob_content.length > Blob::MAXIMUM_TEXT_HIGHLIGHT_SIZE
highlighted = Gitlab::Highlight.highlight(blob_name, blob_content, plain: plain, repository: repository)
+
raw %(<pre class="code highlight"><code>#{highlighted}</code></pre>)
end