mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Added ability to escape double quotes in double quotes
This commit is contained in:
		
							parent
							
								
									5340ed0ad3
								
							
						
					
					
						commit
						dc464a5b10
					
				| @ -12,6 +12,11 @@ var pathTests = []struct { | |||||||
| 	expectedTokens  []interface{} | 	expectedTokens  []interface{} | ||||||
| 	expectedPostFix []interface{} | 	expectedPostFix []interface{} | ||||||
| }{ | }{ | ||||||
|  | 	{ | ||||||
|  | 		`"\""`, | ||||||
|  | 		append(make([]interface{}, 0), "\" (string)"), | ||||||
|  | 		append(make([]interface{}, 0), "\" (string)"), | ||||||
|  | 	}, | ||||||
| 	{ | 	{ | ||||||
| 		`[]|join(".")`, | 		`[]|join(".")`, | ||||||
| 		append(make([]interface{}, 0), "[", "EMPTY", "]", "PIPE", "JOIN", "(", ". (string)", ")"), | 		append(make([]interface{}, 0), "[", "EMPTY", "]", "PIPE", "JOIN", "(", ". (string)", ")"), | ||||||
|  | |||||||
| @ -189,6 +189,7 @@ func stringValue(wrapped bool) lex.Action { | |||||||
| 		if wrapped { | 		if wrapped { | ||||||
| 			value = unwrap(value) | 			value = unwrap(value) | ||||||
| 		} | 		} | ||||||
|  | 		value = strings.ReplaceAll(value, "\\\"", "\"") | ||||||
| 		return &token{TokenType: operationToken, Operation: createValueOperation(value, value)}, nil | 		return &token{TokenType: operationToken, Operation: createValueOperation(value, value)}, nil | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @ -334,7 +335,7 @@ func initLexer() (*lex.Lexer, error) { | |||||||
| 	lexer.Add([]byte(`[Nn][Uu][Ll][Ll]`), nullValue()) | 	lexer.Add([]byte(`[Nn][Uu][Ll][Ll]`), nullValue()) | ||||||
| 	lexer.Add([]byte(`~`), nullValue()) | 	lexer.Add([]byte(`~`), nullValue()) | ||||||
| 
 | 
 | ||||||
| 	lexer.Add([]byte(`"[^"]*"`), stringValue(true)) | 	lexer.Add([]byte(`"([^"\\]*(\\.[^"\\]*)*)"`), stringValue(true)) | ||||||
| 	lexer.Add([]byte(`strenv\([^\)]+\)`), envOp(true)) | 	lexer.Add([]byte(`strenv\([^\)]+\)`), envOp(true)) | ||||||
| 	lexer.Add([]byte(`env\([^\)]+\)`), envOp(false)) | 	lexer.Add([]byte(`env\([^\)]+\)`), envOp(false)) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user