Error while searching for text starting with slash "/"
Summary
In a self-hosted gitlab (v9.4.5), when trying to search, inside a project, for "/" or "/anytexthere", I receive an error 500.
Steps to reproduce
- open a project
- search for "/"
What is the current bug behavior?
Error 500
What is the expected correct behavior?
Display the search result
Relevant logs and/or screenshots
Started GET "/search?utf8=%E2%9C%93&search=%2F&group_id=&project_id=1502&search_code=true&repository_ref=master" for 10.0.0.123 at 2017-08-16 10:03:32 -0300
...
Processing by SearchController#show as HTML
Parameters: {"utf8"=>"✓", "search"=>"/", "group_id"=>"", "project_id"=>"1502", "search_code"=>"true", "repository_ref"=>"master"}
...
Completed 500 Internal Server Error in 541ms (ActiveRecord: 21.9ms)
ActionView::Template::Error (undefined method `encoding' for nil:NilClass):
13: = link_icon
14: = i
15: .blob-content{ data: { blob_id: blob.id } }
16: = highlight(blob.path, blob.data, repository: repository, plain: blob.no_highlighting?)
lib/rouge/formatters/html_gitlab.rb:16:in `stream'
lib/gitlab/highlight.rb:50:in `highlight_plain'
lib/gitlab/highlight.rb:56:in `rescue in highlight_rich'
lib/gitlab/highlight.rb:54:in `highlight_rich'
lib/gitlab/highlight.rb:45:in `highlight_text'
lib/gitlab/highlight.rb:18:in `highlight'
lib/gitlab/highlight.rb:5:in `highlight'
app/helpers/blob_helper.rb:3:in `highlight'
app/views/shared/_file_highlight.html.haml:16:in `_app_views_shared__file_highlight_html_haml___2933675532321824369_70274185183060'
app/views/search/results/_blob.html.haml:13:in `_app_views_search_results__blob_html_haml___3377330441211013036_70274218953640'
app/views/search/_results.html.haml:22:in `_app_views_search__results_html_haml__157471517157666818_70274181746100'
app/views/search/show.html.haml:9:in `_app_views_search_show_html_haml___3381673697331606016_70274194381500'
lib/gitlab/i18n.rb:45:in `with_locale'
lib/gitlab/i18n.rb:51:in `with_user_locale'
app/controllers/application_controller.rb:294:in `set_locale'
lib/gitlab/performance_bar/peek_performance_bar_with_rack_body.rb:16:in `call'
lib/gitlab/middleware/multipart.rb:93:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:16:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
Results of GitLab environment info
Expand for output related to the GitLab application check
All tests passed
Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.3) Git version >= 2.7.3 ? ... yes (2.13.4) Active users: ... 130
Checking GitLab ... Finished
Possible fixes
Edited by Thiago Laubstein