mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		
						commit
						978aef2ae7
					
				@ -36,9 +36,11 @@ func (l *lexer) load(input io.Reader) error {
 | 
			
		||||
// the token starts with a quotes character (")
 | 
			
		||||
// in which case the token goes until the closing
 | 
			
		||||
// quotes (the enclosing quotes are not included).
 | 
			
		||||
// The rest of the line is skipped if a "#"
 | 
			
		||||
// character is read in. Returns true if a token
 | 
			
		||||
// was loaded; false otherwise.
 | 
			
		||||
// Inside quoted strings, quotes may be escaped
 | 
			
		||||
// with a preceding \ character. No other chars
 | 
			
		||||
// 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 {
 | 
			
		||||
	var val []rune
 | 
			
		||||
	var comment, quoted, escaped bool
 | 
			
		||||
@ -74,6 +76,12 @@ func (l *lexer) next() bool {
 | 
			
		||||
			if ch == '\n' {
 | 
			
		||||
				l.line++
 | 
			
		||||
			}
 | 
			
		||||
			if escaped {
 | 
			
		||||
				// only escape quotes
 | 
			
		||||
				if ch != '"' {
 | 
			
		||||
					val = append(val, '\\')
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			val = append(val, ch)
 | 
			
		||||
			escaped = false
 | 
			
		||||
			continue
 | 
			
		||||
 | 
			
		||||
@ -80,6 +80,18 @@ func TestLexer(t *testing.T) {
 | 
			
		||||
				{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
 | 
			
		||||
					break inside" {
 | 
			
		||||
@ -93,6 +105,20 @@ func TestLexer(t *testing.T) {
 | 
			
		||||
				{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\nCR characters",
 | 
			
		||||
			expected: []token{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user