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
91f8656c
Commit
91f8656c
authored
May 15, 2018
by
Jan Provaznik
Committed by
Rémy Coutable
May 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable greedy mode when matching filename
parent
a78b1b27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
jprovazn-null-byte.yml
changelogs/unreleased/jprovazn-null-byte.yml
+5
-0
project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-1
project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+12
-0
No files found.
changelogs/unreleased/jprovazn-null-byte.yml
0 → 100644
View file @
91f8656c
---
title
:
Fix filename matching when processing file or blob search results
merge_request
:
author
:
type
:
fixed
lib/gitlab/project_search_results.rb
View file @
91f8656c
...
...
@@ -59,7 +59,7 @@ module Gitlab
startline
=
0
result
.
each_line
.
each_with_index
do
|
line
,
index
|
prefix
||=
line
.
match
(
/^(?<ref>[^:]*):(?<filename>
.
*)\x00(?<startline>\d+)\x00/
)
&
.
tap
do
|
matches
|
prefix
||=
line
.
match
(
/^(?<ref>[^:]*):(?<filename>
[^\x00]
*)\x00(?<startline>\d+)\x00/
)
&
.
tap
do
|
matches
|
ref
=
matches
[
:ref
]
filename
=
matches
[
:filename
]
startline
=
matches
[
:startline
]
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
91f8656c
...
...
@@ -106,6 +106,18 @@ describe Gitlab::ProjectSearchResults do
end
end
context
'when the matching content contains multiple null bytes'
do
let
(
:search_result
)
{
"master:testdata/foo.txt
\x00
1
\x00
blah
\x00
1
\x00
foo"
}
it
'returns a valid FoundBlob'
do
expect
(
subject
.
filename
).
to
eq
(
'testdata/foo.txt'
)
expect
(
subject
.
basename
).
to
eq
(
'testdata/foo'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
"blah
\x00
1
\x00
foo"
)
end
end
context
'when the search result ends with an empty line'
do
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
'Role models'
,
'master'
)
}
...
...
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