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
e8161769
Commit
e8161769
authored
Apr 22, 2020
by
nicolasdular
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use stricter regex for broadcast target path
parent
d12e63eb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+4
-1
changelogs/unreleased/nicolasdular-improve-target-path-regex.yml
...ogs/unreleased/nicolasdular-improve-target-path-regex.yml
+5
-0
spec/models/broadcast_message_spec.rb
spec/models/broadcast_message_spec.rb
+18
-0
No files found.
app/models/broadcast_message.rb
View file @
e8161769
...
...
@@ -105,7 +105,10 @@ class BroadcastMessage < ApplicationRecord
def
matches_current_path
(
current_path
)
return
true
if
current_path
.
blank?
||
target_path
.
blank?
current_path
.
match
(
Regexp
.
escape
(
target_path
).
gsub
(
'\\*'
,
'.*'
))
escaped
=
Regexp
.
escape
(
target_path
).
gsub
(
'\\*'
,
'.*'
)
regexp
=
Regexp
.
new
"^
#{
escaped
}
$"
,
Regexp
::
IGNORECASE
regexp
.
match
(
current_path
)
end
def
flush_redis_cache
...
...
changelogs/unreleased/nicolasdular-improve-target-path-regex.yml
0 → 100644
View file @
e8161769
---
title
:
Use stricter regex for broadcast target path
merge_request
:
30210
author
:
type
:
changed
spec/models/broadcast_message_spec.rb
View file @
e8161769
...
...
@@ -143,6 +143,24 @@ describe BroadcastMessage do
expect
(
subject
.
call
(
'/group/groupname/issues'
).
length
).
to
eq
(
0
)
end
it
'does not return message if target path has no wild card at the end'
do
create
(
:broadcast_message
,
target_path:
"*/issues"
,
broadcast_type:
broadcast_type
)
expect
(
subject
.
call
(
'/group/issues/test'
).
length
).
to
eq
(
0
)
end
it
'does not return message if target path has wild card at the end'
do
create
(
:broadcast_message
,
target_path:
"/issues/*"
,
broadcast_type:
broadcast_type
)
expect
(
subject
.
call
(
'/group/issues/test'
).
length
).
to
eq
(
0
)
end
it
'does return message if target path has wild card at the beginning and the end'
do
create
(
:broadcast_message
,
target_path:
"*/issues/*"
,
broadcast_type:
broadcast_type
)
expect
(
subject
.
call
(
'/group/issues/test'
).
length
).
to
eq
(
1
)
end
end
describe
'.current'
,
:use_clean_rails_memory_store_caching
do
...
...
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