Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
869877ab
Commit
869877ab
authored
Nov 30, 2017
by
haseeb
Committed by
Rémy Coutable
Nov 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for special charecter in file names
parent
73e48b74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
changelogs/unreleased/40146_fix_special_charecter_search_in_filenames.yml
...eased/40146_fix_special_charecter_search_in_filenames.yml
+5
-0
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+5
-2
spec/lib/gitlab/project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+9
-0
No files found.
changelogs/unreleased/40146_fix_special_charecter_search_in_filenames.yml
0 → 100644
View file @
869877ab
---
title
:
Fix search results when a filename would contain a special character.
merge_request
:
15606
author
:
haseebeqx
type
:
fixed
lib/gitlab/project_search_results.rb
View file @
869877ab
...
@@ -47,8 +47,11 @@ module Gitlab
...
@@ -47,8 +47,11 @@ module Gitlab
startline
=
0
startline
=
0
result
.
each_line
.
each_with_index
do
|
line
,
index
|
result
.
each_line
.
each_with_index
do
|
line
,
index
|
if
line
=~
/^.*:.*:\d+:/
matches
=
line
.
match
(
/^(?<ref>[^:]*):(?<filename>.*):(?<startline>\d+):/
)
ref
,
filename
,
startline
=
line
.
split
(
':'
)
if
matches
ref
=
matches
[
:ref
]
filename
=
matches
[
:filename
]
startline
=
matches
[
:startline
]
startline
=
startline
.
to_i
-
index
startline
=
startline
.
to_i
-
index
extname
=
Regexp
.
escape
(
File
.
extname
(
filename
))
extname
=
Regexp
.
escape
(
File
.
extname
(
filename
))
basename
=
filename
.
sub
(
/
#{
extname
}
$/
,
''
)
basename
=
filename
.
sub
(
/
#{
extname
}
$/
,
''
)
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
869877ab
...
@@ -70,6 +70,15 @@ describe Gitlab::ProjectSearchResults do
...
@@ -70,6 +70,15 @@ describe Gitlab::ProjectSearchResults do
subject
{
described_class
.
parse_search_result
(
search_result
)
}
subject
{
described_class
.
parse_search_result
(
search_result
)
}
it
'can correctly parse filenames including ":"'
do
special_char_result
=
"
\n
master:testdata/project::function1.yaml-1----
\n
master:testdata/project::function1.yaml:2:test: data1
\n
"
blob
=
described_class
.
parse_search_result
(
special_char_result
)
expect
(
blob
.
ref
).
to
eq
(
'master'
)
expect
(
blob
.
filename
).
to
eq
(
'testdata/project::function1.yaml'
)
end
it
"returns a valid FoundBlob"
do
it
"returns a valid FoundBlob"
do
is_expected
.
to
be_an
Gitlab
::
SearchResults
::
FoundBlob
is_expected
.
to
be_an
Gitlab
::
SearchResults
::
FoundBlob
expect
(
subject
.
id
).
to
be_nil
expect
(
subject
.
id
).
to
be_nil
...
...
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