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
1e1e69b9
Commit
1e1e69b9
authored
Jul 27, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Discard byte order mark (fix #962)
parent
cf1b355d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
caddyfile/lexer.go
caddyfile/lexer.go
+11
-0
caddyfile/lexer_test.go
caddyfile/lexer_test.go
+6
-0
No files found.
caddyfile/lexer.go
View file @
1e1e69b9
...
@@ -26,9 +26,20 @@ type (
...
@@ -26,9 +26,20 @@ type (
)
)
// load prepares the lexer to scan an input for tokens.
// load prepares the lexer to scan an input for tokens.
// It discards any leading byte order mark.
func
(
l
*
lexer
)
load
(
input
io
.
Reader
)
error
{
func
(
l
*
lexer
)
load
(
input
io
.
Reader
)
error
{
l
.
reader
=
bufio
.
NewReader
(
input
)
l
.
reader
=
bufio
.
NewReader
(
input
)
l
.
line
=
1
l
.
line
=
1
// discard byte order mark, if present
firstCh
,
_
,
err
:=
l
.
reader
.
ReadRune
()
if
err
==
nil
&&
firstCh
!=
0xFEFF
{
err
:=
l
.
reader
.
UnreadRune
()
if
err
!=
nil
{
return
err
}
}
return
nil
return
nil
}
}
...
...
caddyfile/lexer_test.go
View file @
1e1e69b9
...
@@ -128,6 +128,12 @@ func TestLexer(t *testing.T) {
...
@@ -128,6 +128,12 @@ func TestLexer(t *testing.T) {
{
Line
:
2
,
Text
:
"characters"
},
{
Line
:
2
,
Text
:
"characters"
},
},
},
},
},
{
input
:
"
\xEF\xBB\xBF
:8080"
,
// test with leading byte order mark
expected
:
[]
Token
{
{
Line
:
1
,
Text
:
":8080"
},
},
},
}
}
for
i
,
testCase
:=
range
testCases
{
for
i
,
testCase
:=
range
testCases
{
...
...
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