Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • You'd want to run both seds in the C locale or that will potentially leave some arbitrary command injection vulnerabilities. Try for instance with add=$'\u03b1\ne uname>&2' with GNU sed in a locale using BIG5 or BIG5-HKSCS charset (such as zh_HK on Ubuntu 20.04 for instance) where that U+03B1 (α) is encoded as 0xa3 0x5c (0x5c being also backslash). More generally, it's best to avoid inserting arbitrary data in the code argument of interpreters (like sed here), and when you still do, sanitise like you did but bear in mind backslash escaping is only reliable in the C locale. Commented Mar 6, 2021 at 6:34