Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-05-24 08:59:35 +0300
committerStan Hu <stanhu@gmail.com>2016-06-12 17:36:25 +0300
commit0fdfd2dd6e01648f4daf6853f11a3ffc9a678a55 (patch)
tree985c306c1885c68220ba99a40bd5426ac14d52ce /app/helpers/blob_helper.rb
parentff345f8ba11658c679b423e06bbc42b90af158eb (diff)
Fix Error 500 when viewing a blob with binary characters after the 1024-byte mark
Here was the problem: 1. When determining whether a given blob is viewable text, gitlab_git reads the first 1024 bytes and checks with Linguist whether it is a text or binary file. 2. If the blob is text, GitLab will attempt to display it. 3. However, if the text has binary characters after the first 1024 bytes, then GitLab will attempt to load the entire contents, but the encoding will be ASCII-8BIT since there are binary characters. 4. The Error 500 results when GitLab attempts to display a mix UTF-8 and ASCII-8BIT. To fix this, we load as much data as we are willing to display so that the detection will work properly. Requires an update to gitlab_git: gitlab-org/gitlab_git!86 Closes #13826
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r--app/helpers/blob_helper.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index cec2dc753fe..85559fbc5f5 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -116,7 +116,7 @@ module BlobHelper
end
def blob_text_viewable?(blob)
- blob && blob.text? && !blob.lfs_pointer?
+ blob && blob.text? && !blob.lfs_pointer? && !blob.only_display_raw?
end
def blob_size(blob)