12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | deftype BP:String
extern bl_string_replace(text:String, pat:BP, replacement:String):String
def hl(s:String):String
return "\x1b[36;7m$s\x1b[m"
def (str:String):BP
return ("\"$(str | bl_string_replace(%BP{`",\}, '\@0'))\""):BP
def replace(str:String, pat:String, replacement:String):String
return str|bl_string_replace(%BP[$pat], replacement)
deftype SQL:String
def (str:String):SQL
return "'$(str|replace("'", "''")|hl)'":SQL
def (n:Int):SQL
return ("$n"|hl):SQL
limit := 10
name := "name'; DROP TABLE users; --"
query := %SQL[select * from users where name = $name limit $limit]
say "\x1b[1mSQL Query:\x1b[m $query"
deftype Shell:String
def (str:String):Shell
return ("'" + (str | replace("'", "'\"'\"'") | hl) + "'"):Shell
def (strings:[String]):Shell
ret := %Shell""
for str in strings
ret += %Shell[$str]
between ret += %Shell[ ]
return ret
files := ['one', 'file space', 'malicious `rm -f $HOME`', "don't screw up"]
dest := "tmp"
cmd := %Shell> cp @files $HOME/@dest
say "\x1b[1mShell command:\x1b[m $cmd"
deftype HTML:String
def (str:String):HTML
return (str | replace("&","&") | replace("<","<") | replace(">",">") | replace('"',""") | replace("'","'")|hl):HTML
message := "I <3 things and don't care"
html := %HTML:
<html>
<body>
$message
</body>
html += %HTML[\n</html>]
say "\x1b[1mHTML:\x1b[m\n$html"
|