{ "info": { "author": "Christopher Simpkins", "author_email": "git.simpkins@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "Source Repository: https://github.com/chrissimpkins/shellescape\n\nDescription\n-----------\n\nThe shellescape Python module defines the ``shellescape.quote()`` function that returns a shell-escaped version of a Python string. This is a backport of the ``shlex.quote()`` function from Python 3.4.3 that makes it accessible to users of Python 3 versions < 3.3 and all Python 2.x versions.\n\nquote(s)\n--------\n\nFrom the Python documentation:\n\nReturn a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list.\n\nThis idiom would be unsafe:\n\n.. code-block:: python\n\n\t>>> filename = 'somefile; rm -rf ~'\n\t>>> command = 'ls -l {}'.format(filename)\n\t>>> print(command) # executed by a shell: boom!\n\tls -l somefile; rm -rf ~\n\n\n``quote()`` lets you plug the security hole:\n\n.. code-block:: python\n\n\t>>> command = 'ls -l {}'.format(quote(filename))\n\t>>> print(command)\n\tls -l 'somefile; rm -rf ~'\n\t>>> remote_command = 'ssh home {}'.format(quote(command))\n\t>>> print(remote_command)\n\tssh home 'ls -l '\"'\"'somefile; rm -rf ~'\"'\"''\n\n\nThe quoting is compatible with UNIX shells and with ``shlex.split()``:\n\n.. code-block:: python\n\n\t>>> remote_command = split(remote_command)\n\t>>> remote_command\n\t['ssh', 'home', \"ls -l 'somefile; rm -rf ~'\"]\n\t>>> command = split(remote_command[-1])\n\t>>> command\n\t['ls', '-l', 'somefile; rm -rf ~']\n\n\nUsage\n-----\n\nInclude ``shellescape`` in your project setup.py file ``install_requires`` dependency definition list:\n\n.. code-block:: python\n\n\tsetup(\n\t ...\n\t install_requires=['shellescape'],\n\t ...\n\t)\n\n\nThen import the ``quote`` function into your module(s) and use it as needed:\n\n.. code-block:: python\n\n\t#!/usr/bin/env python\n\t# -*- coding: utf-8 -*-\n\n\tfrom shellescape import quote\n\n\tfilename = \"somefile; rm -rf ~\"\n\tescaped_shell_command = 'ls -l {}'.format(quote(filename))\n\n\nIssue Reporting\n---------------\n\nIssue reporting is available on the `GitHub repository `_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chrissimpkins/shellescape", "keywords": "shell,quote,escape,backport,command line,command,subprocess", "license": "MIT license", "maintainer": null, "maintainer_email": null, "name": "shellescape", "package_url": "https://pypi.org/project/shellescape/", "platform": "any", "project_url": "https://pypi.org/project/shellescape/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/chrissimpkins/shellescape" }, "release_url": "https://pypi.org/project/shellescape/3.4.1/", "requires_dist": null, "requires_python": null, "summary": "Shell escape a string to safely use it as a token in a shell command (backport of Python shlex.quote for Python versions 2.x & < 3.3)", "version": "3.4.1" }, "last_serial": 1544721, "releases": { "3.4.0": [ { "comment_text": "", "digests": { "md5": "84fde126dd9a6ed0eb886caddc09256a", "sha256": "eb203e30725f7c0dbc7ed435973b749c442c68889965b28fd4a4363fe1a808e6" }, "downloads": -1, "filename": "shellescape-3.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "84fde126dd9a6ed0eb886caddc09256a", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4927, "upload_time": "2015-05-08T11:55:25", "url": "https://files.pythonhosted.org/packages/6f/77/71d10cd779daea6473b5d3957fe31af52ea1e0af8b9da4bf0bd653a67c18/shellescape-3.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8ca3b165a9c6a5f78183c05ca49cf2ba", "sha256": "a7c9e5ee7a8bffbdd9a53ccb9f1b50faa9cb659747bbcc0f4337f9005626be95" }, "downloads": -1, "filename": "shellescape-3.4.0.tar.gz", "has_sig": false, "md5_digest": "8ca3b165a9c6a5f78183c05ca49cf2ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4855, "upload_time": "2015-05-08T11:55:22", "url": "https://files.pythonhosted.org/packages/8a/40/a0961dff6e7340d925d92015fb73eb12e03c223befc627af24fb064a545c/shellescape-3.4.0.tar.gz" } ], "3.4.1": [ { "comment_text": "", "digests": { "md5": "5bc6f494f210878685dc9492fbce52e2", "sha256": "3ff2aeb6ce2c5a4e6059fe4a2a745a824f5a3834fe8365a39c5ea691073cfdb6" }, "downloads": -1, "filename": "shellescape-3.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5bc6f494f210878685dc9492fbce52e2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4933, "upload_time": "2015-05-13T01:39:58", "url": "https://files.pythonhosted.org/packages/51/b6/986c99a10040beaaefca1ad6c93bd7738cb8e4f52f6caed13d3ed1caa7e4/shellescape-3.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8dc7545a9a27d19dfcc4d7b33a72c296", "sha256": "e618b2bc13f2553315ca1669995dc10fcc2cae5f1e0fda49035ef02d56f0b358" }, "downloads": -1, "filename": "shellescape-3.4.1.tar.gz", "has_sig": false, "md5_digest": "8dc7545a9a27d19dfcc4d7b33a72c296", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4876, "upload_time": "2015-05-13T01:39:55", "url": "https://files.pythonhosted.org/packages/dd/72/797570d91fd1ba785966c43f12d5a6dec40438ba727dd02dbf636032b0a1/shellescape-3.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5bc6f494f210878685dc9492fbce52e2", "sha256": "3ff2aeb6ce2c5a4e6059fe4a2a745a824f5a3834fe8365a39c5ea691073cfdb6" }, "downloads": -1, "filename": "shellescape-3.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5bc6f494f210878685dc9492fbce52e2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4933, "upload_time": "2015-05-13T01:39:58", "url": "https://files.pythonhosted.org/packages/51/b6/986c99a10040beaaefca1ad6c93bd7738cb8e4f52f6caed13d3ed1caa7e4/shellescape-3.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8dc7545a9a27d19dfcc4d7b33a72c296", "sha256": "e618b2bc13f2553315ca1669995dc10fcc2cae5f1e0fda49035ef02d56f0b358" }, "downloads": -1, "filename": "shellescape-3.4.1.tar.gz", "has_sig": false, "md5_digest": "8dc7545a9a27d19dfcc4d7b33a72c296", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4876, "upload_time": "2015-05-13T01:39:55", "url": "https://files.pythonhosted.org/packages/dd/72/797570d91fd1ba785966c43f12d5a6dec40438ba727dd02dbf636032b0a1/shellescape-3.4.1.tar.gz" } ] }