Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
nexedi
caddy
Commits
978aef2a
Commit
978aef2a
authored
May 08, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
48a12c60
2501691e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
config/parse/lexer.go
config/parse/lexer.go
+11
-3
config/parse/lexer_test.go
config/parse/lexer_test.go
+26
-0
No files found.
config/parse/lexer.go
View file @
978aef2a
...
@@ -36,9 +36,11 @@ func (l *lexer) load(input io.Reader) error {
...
@@ -36,9 +36,11 @@ func (l *lexer) load(input io.Reader) error {
// the token starts with a quotes character (")
// the token starts with a quotes character (")
// in which case the token goes until the closing
// in which case the token goes until the closing
// quotes (the enclosing quotes are not included).
// quotes (the enclosing quotes are not included).
// The rest of the line is skipped if a "#"
// Inside quoted strings, quotes may be escaped
// character is read in. Returns true if a token
// with a preceding \ character. No other chars
// was loaded; false otherwise.
// may be escaped. The rest of the line is skipped
// if a "#" character is read in. Returns true if
// a token was loaded; false otherwise.
func
(
l
*
lexer
)
next
()
bool
{
func
(
l
*
lexer
)
next
()
bool
{
var
val
[]
rune
var
val
[]
rune
var
comment
,
quoted
,
escaped
bool
var
comment
,
quoted
,
escaped
bool
...
@@ -74,6 +76,12 @@ func (l *lexer) next() bool {
...
@@ -74,6 +76,12 @@ func (l *lexer) next() bool {
if
ch
==
'\n'
{
if
ch
==
'\n'
{
l
.
line
++
l
.
line
++
}
}
if
escaped
{
// only escape quotes
if
ch
!=
'"'
{
val
=
append
(
val
,
'\\'
)
}
}
val
=
append
(
val
,
ch
)
val
=
append
(
val
,
ch
)
escaped
=
false
escaped
=
false
continue
continue
...
...
config/parse/lexer_test.go
View file @
978aef2a
...
@@ -80,6 +80,18 @@ func TestLexer(t *testing.T) {
...
@@ -80,6 +80,18 @@ func TestLexer(t *testing.T) {
{
line
:
1
,
text
:
"B"
},
{
line
:
1
,
text
:
"B"
},
},
},
},
},
{
input
:
`"don't\escape"`
,
expected
:
[]
token
{
{
line
:
1
,
text
:
`don't\escape`
},
},
},
{
input
:
`"don't\\escape"`
,
expected
:
[]
token
{
{
line
:
1
,
text
:
`don't\\escape`
},
},
},
{
{
input
:
`A "quoted value with line
input
:
`A "quoted value with line
break inside" {
break inside" {
...
@@ -93,6 +105,20 @@ func TestLexer(t *testing.T) {
...
@@ -93,6 +105,20 @@ func TestLexer(t *testing.T) {
{
line
:
4
,
text
:
"}"
},
{
line
:
4
,
text
:
"}"
},
},
},
},
},
{
input
:
`"C:\php\php-cgi.exe"`
,
expected
:
[]
token
{
{
line
:
1
,
text
:
`C:\php\php-cgi.exe`
},
},
},
{
input
:
`empty "" string`
,
expected
:
[]
token
{
{
line
:
1
,
text
:
`empty`
},
{
line
:
1
,
text
:
``
},
{
line
:
1
,
text
:
`string`
},
},
},
{
{
input
:
"skip those
\r\n
CR characters"
,
input
:
"skip those
\r\n
CR characters"
,
expected
:
[]
token
{
expected
:
[]
token
{
...
...
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