Skip to content

Commit

Permalink
Fixes #7 in a non-regressing way
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Aug 2, 2016
1 parent c7fc65f commit 0d18ab8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.2.6
- Fixes bad handling of escape sequences when ungronning - but properly this time (issue #7)

## 0.2.5
- Fixes bad handling of escape sequences when ungronning (issue #7)

Expand Down
10 changes: 5 additions & 5 deletions ungron.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ func (l *lexer) acceptUntil(delims string) {
// rune contained in the provided string, unless that rune was
// escaped with a backslash
func (l *lexer) acceptUntilUnescaped(delims string) {
for !strings.ContainsRune(delims, l.next()) {
// Hit the ending rune but it was escaped
if l.prev == '\\' {
continue
// Read until we hit an unescaped rune or the end of the input
for {
if strings.ContainsRune(delims, l.next()) && l.prev != '\\' {
l.backup()
return
}
if l.cur == utf8.RuneError {
return
}
}
l.backup()
}

// newLexer returns a new lexer for the provided string
Expand Down
4 changes: 2 additions & 2 deletions ungron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ func TestLex(t *testing.T) {
{`"ba;r"`, typValue},
}},

{`json.foo = "ba\r ;";`, []token{
{`json.foo = "ba\"r ;";`, []token{
{`json`, typBare},
{`foo`, typBare},
{`"ba\r ;"`, typValue},
{`"ba\"r ;"`, typValue},
}},

{`json.value = "\u003c ;"`, []token{
Expand Down

0 comments on commit 0d18ab8

Please sign in to comment.