shellescape-3.4.1/0000755000076500000240000000000012524525551013712 5ustar cesstaff00000000000000shellescape-3.4.1/docs/0000755000076500000240000000000012524525551014642 5ustar cesstaff00000000000000shellescape-3.4.1/docs/LICENSE0000644000076500000240000000755212523031605015647 0ustar cesstaff00000000000000The MIT License (MIT) Copyright (c) 2015 Christopher Simpkins Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SUMMARY OF CHANGES The Python 3.4.3 function `quote` from the `shlex` module (`shlex.quote()`) was backported in order to provide access to this function in earlier versions of Python. The regular expression used to identify unsafe command line strings was modified to: _find_unsafe = re.compile(r'[a-zA-Z0-9_^@%+=:,./-]').search from: _find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.ASCII).search in order to remove the re.ASCII flag which is not available in the Python 2.x re module PSF LICENSE AGREEMENT FOR PYTHON 3.4.3 This LICENSE AGREEMENT is between the Python Software Foundation (“PSF”), and the Individual or Organization (“Licensee”) accessing and otherwise using Python 3.4.3 software in source or binary form and its associated documentation. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python 3.4.3 alone or in any derivative version, provided, however, that PSF’s License Agreement and PSF’s notice of copyright, i.e., “Copyright © 2001-2015 Python Software Foundation; All Rights Reserved” are retained in Python 3.4.3 alone or in any derivative version prepared by Licensee. In the event Licensee prepares a derivative work that is based on or incorporates Python 3.4.3 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 3.4.3. PSF is making Python 3.4.3 available to Licensee on an “AS IS” basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 3.4.3 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.4.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.4.3, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This License Agreement will automatically terminate upon a material breach of its terms and conditions. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. By copying, installing or otherwise using Python 3.4.3, Licensee agrees to be bound by the terms and conditions of this License Agreement. shellescape-3.4.1/docs/README.rst0000644000076500000240000000402112523170372016322 0ustar cesstaff00000000000000Source Repository: https://github.com/chrissimpkins/shellescape Description ----------- The 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. quote(s) -------- From the Python documentation: Return 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. This idiom would be unsafe: .. code-block:: python >>> filename = 'somefile; rm -rf ~' >>> command = 'ls -l {}'.format(filename) >>> print(command) # executed by a shell: boom! ls -l somefile; rm -rf ~ ``quote()`` lets you plug the security hole: .. code-block:: python >>> command = 'ls -l {}'.format(quote(filename)) >>> print(command) ls -l 'somefile; rm -rf ~' >>> remote_command = 'ssh home {}'.format(quote(command)) >>> print(remote_command) ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"'' The quoting is compatible with UNIX shells and with ``shlex.split()``: .. code-block:: python >>> remote_command = split(remote_command) >>> remote_command ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"] >>> command = split(remote_command[-1]) >>> command ['ls', '-l', 'somefile; rm -rf ~'] Usage ----- Include ``shellescape`` in your project setup.py file ``install_requires`` dependency definition list: .. code-block:: python setup( ... install_requires=['shellescape'], ... ) Then import the ``quote`` function into your module(s) and use it as needed: .. code-block:: python #!/usr/bin/env python # -*- coding: utf-8 -*- from shellescape import quote filename = "somefile; rm -rf ~" escaped_shell_command = 'ls -l {}'.format(quote(filename)) Issue Reporting --------------- Issue reporting is available on the `GitHub repository `_ shellescape-3.4.1/lib/0000755000076500000240000000000012524525551014460 5ustar cesstaff00000000000000shellescape-3.4.1/lib/shellescape/0000755000076500000240000000000012524525551016750 5ustar cesstaff00000000000000shellescape-3.4.1/lib/shellescape/__init__.py0000644000076500000240000000010712524524776021067 0ustar cesstaff00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- from .main import quote shellescape-3.4.1/lib/shellescape/main.py0000644000076500000240000000067512523032421020242 0ustar cesstaff00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import re _find_unsafe = re.compile(r'[a-zA-Z0-9_^@%+=:,./-]').search def quote(s): """Return a shell-escaped version of the string *s*.""" if not s: return "''" if _find_unsafe(s) is None: return s # use single quotes, and put single quotes into double quotes # the string $'b is then quoted as '$'"'"'b' return "'" + s.replace("'", "'\"'\"'") + "'" shellescape-3.4.1/lib/shellescape/settings.py0000644000076500000240000000075612524524615021172 0ustar cesstaff00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # Application Name # ------------------------------------------------------------------------------ app_name = 'shellescape' # ------------------------------------------------------------------------------ # Version Number # ------------------------------------------------------------------------------ major_version = "3" minor_version = "4" patch_version = "1" shellescape-3.4.1/lib/shellescape.egg-info/0000755000076500000240000000000012524525551020442 5ustar cesstaff00000000000000shellescape-3.4.1/lib/shellescape.egg-info/dependency_links.txt0000644000076500000240000000000112524525547024515 0ustar cesstaff00000000000000 shellescape-3.4.1/lib/shellescape.egg-info/PKG-INFO0000644000076500000240000000711312524525547021546 0ustar cesstaff00000000000000Metadata-Version: 1.1 Name: shellescape Version: 3.4.1 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) Home-page: https://github.com/chrissimpkins/shellescape Author: Christopher Simpkins Author-email: git.simpkins@gmail.com License: MIT license Description: Source Repository: https://github.com/chrissimpkins/shellescape Description ----------- The 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. quote(s) -------- From the Python documentation: Return 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. This idiom would be unsafe: .. code-block:: python >>> filename = 'somefile; rm -rf ~' >>> command = 'ls -l {}'.format(filename) >>> print(command) # executed by a shell: boom! ls -l somefile; rm -rf ~ ``quote()`` lets you plug the security hole: .. code-block:: python >>> command = 'ls -l {}'.format(quote(filename)) >>> print(command) ls -l 'somefile; rm -rf ~' >>> remote_command = 'ssh home {}'.format(quote(command)) >>> print(remote_command) ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"'' The quoting is compatible with UNIX shells and with ``shlex.split()``: .. code-block:: python >>> remote_command = split(remote_command) >>> remote_command ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"] >>> command = split(remote_command[-1]) >>> command ['ls', '-l', 'somefile; rm -rf ~'] Usage ----- Include ``shellescape`` in your project setup.py file ``install_requires`` dependency definition list: .. code-block:: python setup( ... install_requires=['shellescape'], ... ) Then import the ``quote`` function into your module(s) and use it as needed: .. code-block:: python #!/usr/bin/env python # -*- coding: utf-8 -*- from shellescape import quote filename = "somefile; rm -rf ~" escaped_shell_command = 'ls -l {}'.format(quote(filename)) Issue Reporting --------------- Issue reporting is available on the `GitHub repository `_ Keywords: shell,quote,escape,backport,command line,command,subprocess Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Operating System :: Microsoft :: Windows shellescape-3.4.1/lib/shellescape.egg-info/SOURCES.txt0000644000076500000240000000044712524525547022340 0ustar cesstaff00000000000000MANIFEST.in setup.cfg setup.py docs/LICENSE docs/README.rst lib/shellescape/__init__.py lib/shellescape/main.py lib/shellescape/settings.py lib/shellescape.egg-info/PKG-INFO lib/shellescape.egg-info/SOURCES.txt lib/shellescape.egg-info/dependency_links.txt lib/shellescape.egg-info/top_level.txtshellescape-3.4.1/lib/shellescape.egg-info/top_level.txt0000644000076500000240000000001412524525547023174 0ustar cesstaff00000000000000shellescape shellescape-3.4.1/MANIFEST.in0000644000076500000240000000003112523015636015437 0ustar cesstaff00000000000000recursive-include docs * shellescape-3.4.1/PKG-INFO0000644000076500000240000000711312524525551015011 0ustar cesstaff00000000000000Metadata-Version: 1.1 Name: shellescape Version: 3.4.1 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) Home-page: https://github.com/chrissimpkins/shellescape Author: Christopher Simpkins Author-email: git.simpkins@gmail.com License: MIT license Description: Source Repository: https://github.com/chrissimpkins/shellescape Description ----------- The 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. quote(s) -------- From the Python documentation: Return 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. This idiom would be unsafe: .. code-block:: python >>> filename = 'somefile; rm -rf ~' >>> command = 'ls -l {}'.format(filename) >>> print(command) # executed by a shell: boom! ls -l somefile; rm -rf ~ ``quote()`` lets you plug the security hole: .. code-block:: python >>> command = 'ls -l {}'.format(quote(filename)) >>> print(command) ls -l 'somefile; rm -rf ~' >>> remote_command = 'ssh home {}'.format(quote(command)) >>> print(remote_command) ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"'' The quoting is compatible with UNIX shells and with ``shlex.split()``: .. code-block:: python >>> remote_command = split(remote_command) >>> remote_command ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"] >>> command = split(remote_command[-1]) >>> command ['ls', '-l', 'somefile; rm -rf ~'] Usage ----- Include ``shellescape`` in your project setup.py file ``install_requires`` dependency definition list: .. code-block:: python setup( ... install_requires=['shellescape'], ... ) Then import the ``quote`` function into your module(s) and use it as needed: .. code-block:: python #!/usr/bin/env python # -*- coding: utf-8 -*- from shellescape import quote filename = "somefile; rm -rf ~" escaped_shell_command = 'ls -l {}'.format(quote(filename)) Issue Reporting --------------- Issue reporting is available on the `GitHub repository `_ Keywords: shell,quote,escape,backport,command line,command,subprocess Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Operating System :: Microsoft :: Windows shellescape-3.4.1/setup.cfg0000644000076500000240000000012212524525551015526 0ustar cesstaff00000000000000[wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 shellescape-3.4.1/setup.py0000644000076500000240000000417212523121754015424 0ustar cesstaff00000000000000import os import re from setuptools import setup, find_packages def docs_read(fname): return open(os.path.join(os.path.dirname(__file__), 'docs', fname)).read() def version_read(): settings_file = open(os.path.join(os.path.dirname(__file__), 'lib', 'shellescape', 'settings.py')).read() major_regex = """major_version\s*?=\s*?["']{1}(\d+)["']{1}""" minor_regex = """minor_version\s*?=\s*?["']{1}(\d+)["']{1}""" patch_regex = """patch_version\s*?=\s*?["']{1}(\d+)["']{1}""" major_match = re.search(major_regex, settings_file) minor_match = re.search(minor_regex, settings_file) patch_match = re.search(patch_regex, settings_file) major_version = major_match.group(1) minor_version = minor_match.group(1) patch_version = patch_match.group(1) if len(major_version) == 0: major_version = 0 if len(minor_version) == 0: minor_version = 0 if len(patch_version) == 0: patch_version = 0 return major_version + "." + minor_version + "." + patch_version setup( name='shellescape', version=version_read(), description='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)', long_description=(docs_read('README.rst')), url='https://github.com/chrissimpkins/shellescape', license='MIT license', author='Christopher Simpkins', author_email='git.simpkins@gmail.com', platforms=['any'], packages=find_packages("lib"), package_dir={'': 'lib'}, keywords='shell,quote,escape,backport,command line,command,subprocess', include_package_data=True, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Natural Language :: English', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Operating System :: MacOS :: MacOS X', 'Operating System :: POSIX', 'Operating System :: Unix', 'Operating System :: Microsoft :: Windows' ], )