[#98] fix panic when heredoc is not closed
This commit is contained in:
		
							parent
							
								
									15e7237b45
								
							
						
					
					
						commit
						e1686cb83c
					
				| @ -140,6 +140,10 @@ func (lex *Lexer) isHeredocEndSince73(p int) bool { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	if p == len(lex.data) { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	for lex.data[p] == ' ' || lex.data[p] == '\t' { | ||||
| 		p++ | ||||
| 	} | ||||
|  | ||||
| @ -1091,6 +1091,34 @@ CAT;` | ||||
| 	assert.DeepEqual(t, expected, actual) | ||||
| } | ||||
| 
 | ||||
| func TestHereDocUnclosed(t *testing.T) { | ||||
| 	src := "<?<<<'S'\n" | ||||
| 
 | ||||
| 	expected := []string{ | ||||
| 		token.T_START_HEREDOC.String(), | ||||
| 	} | ||||
| 
 | ||||
| 	config := cfg.Config{ | ||||
| 		Version: &version.Version{ | ||||
| 			Major: 7, | ||||
| 			Minor: 4, | ||||
| 		}, | ||||
| 	} | ||||
| 	lexer := NewLexer([]byte(src), config) | ||||
| 	actual := []string{} | ||||
| 
 | ||||
| 	for { | ||||
| 		tkn := lexer.Lex() | ||||
| 		if tkn.ID == 0 { | ||||
| 			break | ||||
| 		} | ||||
| 
 | ||||
| 		actual = append(actual, tkn.ID.String()) | ||||
| 	} | ||||
| 
 | ||||
| 	assert.DeepEqual(t, expected, actual) | ||||
| } | ||||
| 
 | ||||
| func TestInlineHtmlNopTokens(t *testing.T) { | ||||
| 	src := `<?php | ||||
| 		$a; ?> test <?php | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user