File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -363,7 +363,8 @@ func (s *Lexer) readString() (Token, *gqlerror.Error) {
363363
364364 escape := s .Input [s .end + 1 ]
365365
366- if escape == 'u' {
366+ switch escape {
367+ case 'u' :
367368 if s .end + 6 >= inputLen {
368369 s .end ++
369370 s .endRunes ++
@@ -377,49 +378,46 @@ func (s *Lexer) readString() (Token, *gqlerror.Error) {
377378 return s .makeError ("Invalid character escape sequence: \\ %s." , s .Input [s .end :s .end + 5 ])
378379 }
379380 buf .WriteRune (r )
380- s .end += 6
381- s .endRunes += 6
382- } else {
383- switch escape {
384- case '"' , '/' , '\\' :
385- buf .WriteByte (escape )
386- case 'b' :
387- buf .WriteByte ('\b' )
388- case 'f' :
389- buf .WriteByte ('\f' )
390- case 'n' :
391- buf .WriteByte ('\n' )
392- case 'r' :
393- buf .WriteByte ('\r' )
394- case 't' :
395- buf .WriteByte ('\t' )
396- case 'x' :
397- if s .end + 4 >= inputLen {
398- s .end ++
399- s .endRunes ++
400- break
401- }
402- // look two ahead
403- r , ok := unhex2 (s .Input [s .end + 2 : s .end + 4 ])
404- if ! ok {
405- // if it's not a correct rune, then we treat it as a literal and move o
406- buf .WriteString (s .Input [s .end : s .end + 2 ])
407- s .end += 2
408- s .endRunes += 2
409- continue
410- }
411- buf .WriteRune (r )
381+ s .end += 4 // because at the end of this we're going to += 2
382+ s .endRunes += 4
383+ case '"' , '/' , '\\' :
384+ buf .WriteByte (escape )
385+ case 'b' :
386+ buf .WriteByte ('\b' )
387+ case 'f' :
388+ buf .WriteByte ('\f' )
389+ case 'n' :
390+ buf .WriteByte ('\n' )
391+ case 'r' :
392+ buf .WriteByte ('\r' )
393+ case 't' :
394+ buf .WriteByte ('\t' )
395+ case 'x' :
396+ if s .end + 4 >= inputLen {
397+ s .end ++
398+ s .endRunes ++
399+ break
400+ }
401+ // look two ahead
402+ r , ok := unhex2 (s .Input [s .end + 2 : s .end + 4 ])
403+ if ! ok {
404+ // if it's not a correct rune, then we treat it as a literal and move o
405+ buf .WriteString (s .Input [s .end : s .end + 2 ])
412406 s .end += 2
413407 s .endRunes += 2
414-
415- default :
416- s .end += 1
417- s .endRunes += 1
418- return s .makeError ("Invalid character escape sequence: \\ %s." , string (escape ))
408+ continue
419409 }
410+ buf .WriteRune (r )
420411 s .end += 2
421412 s .endRunes += 2
413+
414+ default :
415+ s .end += 1
416+ s .endRunes += 1
417+ return s .makeError ("Invalid character escape sequence: \\ %s." , string (escape ))
422418 }
419+ s .end += 2
420+ s .endRunes += 2
423421 }
424422 }
425423
You can’t perform that action at this time.
0 commit comments