Giter Club home page Giter Club logo

shell-escape's Introduction

shell-escape

Build Status

Documentation

Escape characters that may have a special meaning in a shell.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

shell-escape's People

Contributors

sfackler avatar cuviper avatar

Stargazers

@RandyMcMillan avatar  avatar  avatar John Nunley avatar MOZGIII avatar maowtm avatar  avatar  avatar Clement Rey avatar Arne  Christian Beer avatar  avatar Sven avatar Rust avatar Jiayu Yi avatar Yiannis Marangos avatar Andrej Mihajlov avatar Frank Benkstein avatar  avatar David Peter avatar

Watchers

James Cloos avatar  avatar  avatar Frank Benkstein avatar Jiahao XU avatar  avatar

shell-escape's Issues

zsh parses backslashes in single quotes (sometimes)

Given:

echo '\\\x41'

bash and other POSIX-compliant shells pass the contents through unmangled:

\\\x41

but zsh parses both \\ and \x41, producing:

\A

This does not render shell-escape's escaping insecure, because zsh doesn't allow escaping the closing single quote โ€“ i.e. '\' is valid and produces a backslash. However, it does render it incorrect in some cases. For maximum compatibility, it would be best if shell-escape treated \ similarly to ' and !.

Support for OsString

Hi,

Great piece of work. However I face issues using it on Windows. It forces me to go through UTF-8 String, but Windows uses UTF-16 UCS2 strings. So it's incompatible in a way with the platform.

Missing several shell metacharacters

The UNIX implementation only escapes the following characters:

const SHELL_SPECIAL: &'static str = r#" \$'"`!"#;

It should escape at least the following characters (and possibly others):

const SHELL_SPECIAL: &'static str = "|&;<>()$`\\\"' \t\n*?[#~=%!{}";

Feature wishes

  • switch to double quotes instead of single quotes to solve #6 (?)
  • use $'\n' to escape newline and other control characters (this works for bash, so maybe escape() should take an argument like Shell::Bash)
  • add surrounding quotes only if the argument contains spaces
    • to create a nicer output that is also displayable to the user
    • if there is a choice the user should maybe also be able to choose which quotes he prefers, like: escape(โ€ฆ, Shell::Bash(Quotes::Single))

I just wanted to leave those ideas here as a note. Maybe I implement them sometime in the future (maybe not).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.