mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-11-03 19:30:54 +00:00 
			
		
		
		
	Fixed Q003 (avoidable-escaped-quote): Change outer quotes to avoid escaping inner quotes
This commit is contained in:
		
							parent
							
								
									2dc4dd1e1a
								
							
						
					
					
						commit
						d7d91eeb79
					
				@ -247,7 +247,7 @@ class SedReplace(Grammar):
 | 
			
		||||
class EchoPipe(Grammar):
 | 
			
		||||
	grammar = OPTIONAL(SPACE), L("echo "), REST_OF_LINE, L(' | '), REST_OF_LINE, EOL
 | 
			
		||||
	def value(self):
 | 
			
		||||
		text = " ".join(f"\"{s}\"" for s in self[2].string.split(" "))
 | 
			
		||||
		text = " ".join(f'"{s}"' for s in self[2].string.split(" "))
 | 
			
		||||
		return "<pre class='shell'><div>echo " + recode_bash(text) + r" \<br> | " + recode_bash(self[4].string) + "</div></pre>\n"
 | 
			
		||||
 | 
			
		||||
def shell_line(bash):
 | 
			
		||||
@ -377,7 +377,7 @@ def recode_bash(s):
 | 
			
		||||
			tok = tok.replace(c, "\\" + c)
 | 
			
		||||
		tok = fixup_tokens(tok)
 | 
			
		||||
		if " " in tok or '"' in tok:
 | 
			
		||||
			tok = tok.replace("\"", "\\\"")
 | 
			
		||||
			tok = tok.replace('"', '\\"')
 | 
			
		||||
			tok = '"' + tok +'"'
 | 
			
		||||
		else:
 | 
			
		||||
			tok = tok.replace("'", "\\'")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user