BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
06a226a1
Commit
06a226a1
authored
Mar 12, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code and wiki search results when filename is non-ASCII
Previously, we only handled non-ASCII file contents, but the name itself can be non-ASCII.
parent
d47449e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
fix-code-search-500-with-non-ascii-filename.yml
...nreleased/fix-code-search-500-with-non-ascii-filename.yml
+5
-0
search_results.rb
lib/gitlab/search_results.rb
+2
-2
project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+14
-2
No files found.
changelogs/unreleased/fix-code-search-500-with-non-ascii-filename.yml
0 → 100644
View file @
06a226a1
---
title
:
Fix code and wiki search results when filename is non-ASCII
merge_request
:
author
:
type
:
fixed
lib/gitlab/search_results.rb
View file @
06a226a1
...
...
@@ -7,8 +7,8 @@ module Gitlab
def
initialize
(
opts
=
{})
@id
=
opts
.
fetch
(
:id
,
nil
)
@filename
=
opts
.
fetch
(
:filename
,
nil
)
@basename
=
opts
.
fetch
(
:basename
,
nil
)
@filename
=
encode_utf8
(
opts
.
fetch
(
:filename
,
nil
)
)
@basename
=
encode_utf8
(
opts
.
fetch
(
:basename
,
nil
)
)
@ref
=
opts
.
fetch
(
:ref
,
nil
)
@startline
=
opts
.
fetch
(
:startline
,
nil
)
@data
=
encode_utf8
(
opts
.
fetch
(
:data
,
nil
))
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
06a226a1
...
...
@@ -108,14 +108,26 @@ describe Gitlab::ProjectSearchResults do
context
'when the search returns non-ASCII data'
do
context
'with UTF-8'
do
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
"файл"
,
'master'
)
}
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
'файл'
,
'master'
)
}
it
'returns results as UTF-8'
do
expect
(
subject
.
filename
).
to
eq
(
'encoding/russian.rb'
)
expect
(
subject
.
basename
).
to
eq
(
'encoding/russian'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
"Хороший файл"
)
expect
(
subject
.
data
).
to
eq
(
'Хороший файл'
)
end
end
context
'with UTF-8 in the filename'
do
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
'webhook'
,
'master'
)
}
it
'returns results as UTF-8'
do
expect
(
subject
.
filename
).
to
eq
(
'encoding/テスト.txt'
)
expect
(
subject
.
basename
).
to
eq
(
'encoding/テスト'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
3
)
expect
(
subject
.
data
).
to
include
(
'WebHookの確認'
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment