mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
bug fix
This commit is contained in:
parent
b469dea315
commit
49202930ff
@ -7,14 +7,16 @@ import (
|
|||||||
type State byte
|
type State byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StateContent State = 0
|
StateContent State = iota
|
||||||
StateEscape State = 1
|
StateEscape
|
||||||
StateDoubleQuote State = 2
|
StateDoubleQuote
|
||||||
StateSingleQuote State = 3
|
StateDoubleQuoteEscape
|
||||||
StateComment State = 4
|
StateSingleQuote
|
||||||
StateSlash State = 5
|
StateSingleQuoteEscape
|
||||||
StateMultilineComment State = 6
|
StateComment
|
||||||
StateMultilineCommentStar State = 7
|
StateSlash
|
||||||
|
StateMultilineComment
|
||||||
|
StateMultilineCommentStar
|
||||||
)
|
)
|
||||||
|
|
||||||
type Reader struct {
|
type Reader struct {
|
||||||
@ -51,15 +53,31 @@ func (v *Reader) Read(b []byte) (int, error) {
|
|||||||
p = append(p, x)
|
p = append(p, x)
|
||||||
v.state = StateContent
|
v.state = StateContent
|
||||||
case StateDoubleQuote:
|
case StateDoubleQuote:
|
||||||
if x == '"' {
|
switch x {
|
||||||
|
case '"':
|
||||||
v.state = StateContent
|
v.state = StateContent
|
||||||
|
p = append(p, x)
|
||||||
|
case '\\':
|
||||||
|
v.state = StateDoubleQuoteEscape
|
||||||
|
default:
|
||||||
|
p = append(p, x)
|
||||||
}
|
}
|
||||||
p = append(p, x)
|
case StateDoubleQuoteEscape:
|
||||||
|
p = append(p, '\\', x)
|
||||||
|
v.state = StateDoubleQuote
|
||||||
case StateSingleQuote:
|
case StateSingleQuote:
|
||||||
if x == '\'' {
|
switch x {
|
||||||
|
case '\'':
|
||||||
v.state = StateContent
|
v.state = StateContent
|
||||||
|
p = append(p, x)
|
||||||
|
case '\\':
|
||||||
|
v.state = StateSingleQuoteEscape
|
||||||
|
default:
|
||||||
|
p = append(p, x)
|
||||||
}
|
}
|
||||||
p = append(p, x)
|
case StateSingleQuoteEscape:
|
||||||
|
p = append(p, '\\', x)
|
||||||
|
v.state = StateSingleQuote
|
||||||
case StateComment:
|
case StateComment:
|
||||||
if x == '\n' {
|
if x == '\n' {
|
||||||
v.state = StateContent
|
v.state = StateContent
|
||||||
|
@ -32,6 +32,7 @@ text 2*/`, `
|
|||||||
text text 2*`},
|
text text 2*`},
|
||||||
{`"//"content`, `"//"content`},
|
{`"//"content`, `"//"content`},
|
||||||
{`abcd'//'abcd`, `abcd'//'abcd`},
|
{`abcd'//'abcd`, `abcd'//'abcd`},
|
||||||
|
{`"\""`, `"\""`},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range data {
|
for _, testCase := range data {
|
||||||
|
Loading…
Reference in New Issue
Block a user