@register.filter(is_safe=True)
@defaultfilters.stringfilter
def shellfilter(value):
 replacements = {'\\': '\\\\', '`': '\\`', "'": "\\'", '"': '\\"'}
 for (search, repl) in replacements.items():
  value = value.replace(search, repl)
 return safestring.mark_safe(value)

@ register . filter ( is_safe = True ) @ defaultfilters . stringfilter def shellfilter ( value ) : replacements = { '\\' : '\\\\' , '`' : '\\`' , "'" : "\\'" , '"' : '\\"' } for ( search , repl ) in replacements . items ( ) : value = value . replace ( search , repl ) return safestring . mark_safe ( value )
replace html chars for shell usage .