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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
ac65257c
Commit
ac65257c
authored
May 14, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise variables statement exception if pattern is invalid
parent
b784a985
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
6 deletions
+17
-6
lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
+4
-2
lib/gitlab/ci/pipeline/expression/parser.rb
lib/gitlab/ci/pipeline/expression/parser.rb
+2
-0
spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
.../lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
+9
-2
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
+1
-1
spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
+1
-1
No files found.
lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
View file @
ac65257c
...
...
@@ -11,8 +11,10 @@ module Gitlab
end
def
evaluate
(
variables
=
{})
Gitlab
::
UntrustedRegexp
.
new
(
@value
.
to_s
)
# TODO raise LexerError / ParserError in case of RegexpError
# TODO multiline support
@regexp
=
Gitlab
::
UntrustedRegexp
.
new
(
@value
)
rescue
RegexpError
raise
Parser
::
ParserError
,
'Invalid regular expression!'
end
def
self
.
build
(
string
)
...
...
lib/gitlab/ci/pipeline/expression/parser.rb
View file @
ac65257c
...
...
@@ -3,6 +3,8 @@ module Gitlab
module
Pipeline
module
Expression
class
Parser
ParserError
=
Class
.
new
(
Statement
::
StatementError
)
def
initialize
(
tokens
)
@tokens
=
tokens
.
to_enum
@nodes
=
[]
...
...
spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
View file @
ac65257c
...
...
@@ -47,9 +47,16 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do
describe
'#evaluate'
do
it
'returns a regular expression'
do
string
=
described_class
.
new
(
'abc'
)
regexp
=
described_class
.
new
(
'abc'
)
expect
(
string
.
evaluate
).
to
eq
Gitlab
::
UntrustedRegexp
.
new
(
'abc'
)
expect
(
regexp
.
evaluate
).
to
eq
Gitlab
::
UntrustedRegexp
.
new
(
'abc'
)
end
it
'raises error if evaluated regexp is not valid'
do
regexp
=
described_class
.
new
(
'invalid ( .*'
)
expect
{
regexp
.
evaluate
}
.
to
raise_error
(
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Parser
::
ParserError
)
end
end
end
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
View file @
ac65257c
require
'spec_helper'
require
'
fast_
spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Parser
do
describe
'#tree'
do
...
...
spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
View file @
ac65257c
require
'spec_helper'
require
'
fast_
spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Token
do
let
(
:value
)
{
'$VARIABLE'
}
...
...
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