| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b1c261 commit 593800e
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -861,7 +861,7 @@ def pull( | |||
| 861 | 861 | self._assert_refspec() | |
| 862 | 862 | kwargs = add_progress(kwargs, self.repo.git, progress) | |
| 863 | 863 | ||
| 864 | - refspec = Git._unpack_args(refspec or []) | ||
| 864 | + refspec = Git._Git__unpack_args(refspec or []) | ||
| 865 | 865 | if not allow_unsafe_protocols: | |
| 866 | 866 | for ref in refspec: | |
| 867 | 867 | Git.check_unsafe_protocols(ref) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,10 +37,9 @@ | |||
| 37 | 37 | import gitdb | |
| 38 | 38 | ||
| 39 | 39 | try: | |
| 40 | - import pathlib | ||
| 40 | + from pathlib import Path | ||
| 41 | 41 | except ImportError: | |
| 42 | - pathlib = None | ||
| 43 | - | ||
| 42 | + from pathlib2 import Path | ||
| 44 | 43 | ||
| 45 | 44 | log = logging.getLogger(__name__) | |
| 46 | 45 | ||
@@ -982,6 +981,8 @@ def _clone( | |||
| 982 | 981 | ||
| 983 | 982 | if not allow_unsafe_protocols: | |
| 984 | 983 | Git.check_unsafe_protocols(str(url)) | |
| 984 | + if not allow_unsafe_options: | ||
| 985 | + Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options) | ||
| 985 | 986 | if not allow_unsafe_options and multi_options: | |
| 986 | 987 | Git.check_unsafe_options(options=multi_options, unsafe_options=cls.unsafe_git_clone_options) | |
| 987 | 988 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,15 +72,15 @@ def test_call_process_calls_execute(self, git): | |||
| 72 | 72 | assert_equal(git.call_args, ((['git', 'version'],), {})) | |
| 73 | 73 | ||
| 74 | 74 | def test_call_unpack_args_unicode(self): | |
| 75 | - args = Git._unpack_args(u'Unicode€™') | ||
| 75 | + args = Git._Git__unpack_args(u'Unicode€™') | ||
| 76 | 76 | if PY3: | |
| 77 | 77 | mangled_value = 'Unicode\u20ac\u2122' | |
| 78 | 78 | else: | |
| 79 | 79 | mangled_value = 'Unicode\xe2\x82\xac\xe2\x84\xa2' | |
| 80 | 80 | assert_equal(args, [mangled_value]) | |
| 81 | 81 | ||
| 82 | 82 | def test_call_unpack_args(self): | |
| 83 | - args = Git._unpack_args(['git', 'log', '--', u'Unicode€™']) | ||
| 83 | + args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€™']) | ||
| 84 | 84 | if PY3: | |
| 85 | 85 | mangled_value = 'Unicode\u20ac\u2122' | |
| 86 | 86 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,11 @@ | |||
| 22 | 22 | GitCommandError, | |
| 23 | 23 | ) | |
| 24 | 24 | from git.cmd import Git | |
| 25 | - from pathlib import Path | ||
| 25 | + try: | ||
| 26 | + from pathlib import Path | ||
| 27 | + except ImportError: | ||
| 28 | + from pathlib2 import Path | ||
| 29 | + | ||
| 26 | 30 | from git.exc import UnsafeOptionError, UnsafeProtocolError | |
| 27 | 31 | from git.compat import string_types | |
| 28 | 32 | from git.test.lib import ( | |
@@ -726,7 +730,7 @@ def test_set_unsafe_url_allowed(self, rw_repo): | |||
| 726 | 730 | tmp_file = tmp_dir / "pwn" | |
| 727 | 731 | remote = rw_repo.remote("origin") | |
| 728 | 732 | urls = [ | |
| 729 | - f"ext::sh -c touch% {tmp_file}", | ||
| 733 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 730 | 734 | "fd::17/foo", | |
| 731 | 735 | ] | |
| 732 | 736 | for url in urls: | |
@@ -740,7 +744,7 @@ def test_add_unsafe_url(self, rw_repo): | |||
| 740 | 744 | tmp_file = tmp_dir / "pwn" | |
| 741 | 745 | remote = rw_repo.remote("origin") | |
| 742 | 746 | urls = [ | |
| 743 | - f"ext::sh -c touch% {tmp_file}", | ||
| 747 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 744 | 748 | "fd::17/foo", | |
| 745 | 749 | ] | |
| 746 | 750 | for url in urls: | |
@@ -754,7 +758,7 @@ def test_add_unsafe_url_allowed(self, rw_repo): | |||
| 754 | 758 | tmp_file = tmp_dir / "pwn" | |
| 755 | 759 | remote = rw_repo.remote("origin") | |
| 756 | 760 | urls = [ | |
| 757 | - f"ext::sh -c touch% {tmp_file}", | ||
| 761 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 758 | 762 | "fd::17/foo", | |
| 759 | 763 | ] | |
| 760 | 764 | for url in urls: | |
@@ -767,7 +771,7 @@ def test_create_remote_unsafe_url(self, rw_repo): | |||
| 767 | 771 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 768 | 772 | tmp_file = tmp_dir / "pwn" | |
| 769 | 773 | urls = [ | |
| 770 | - f"ext::sh -c touch% {tmp_file}", | ||
| 774 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 771 | 775 | "fd::17/foo", | |
| 772 | 776 | ] | |
| 773 | 777 | for url in urls: | |
@@ -780,12 +784,12 @@ def test_create_remote_unsafe_url_allowed(self, rw_repo): | |||
| 780 | 784 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 781 | 785 | tmp_file = tmp_dir / "pwn" | |
| 782 | 786 | urls = [ | |
| 783 | - f"ext::sh -c touch% {tmp_file}", | ||
| 787 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 784 | 788 | "fd::17/foo", | |
| 785 | 789 | ] | |
| 786 | 790 | for i, url in enumerate(urls): | |
| 787 | 791 | remote = Remote.create( | |
| 788 | - rw_repo, f"origin{i}", url, allow_unsafe_protocols=True | ||
| 792 | + rw_repo, "origin"+str(i), url, allow_unsafe_protocols=True | ||
| 789 | 793 | ) | |
| 790 | 794 | assert remote.url == url | |
| 791 | 795 | assert not tmp_file.exists() | |
@@ -796,7 +800,7 @@ def test_fetch_unsafe_url(self, rw_repo): | |||
| 796 | 800 | tmp_file = tmp_dir / "pwn" | |
| 797 | 801 | remote = rw_repo.remote("origin") | |
| 798 | 802 | urls = [ | |
| 799 | - f"ext::sh -c touch% {tmp_file}", | ||
| 803 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 800 | 804 | "fd::17/foo", | |
| 801 | 805 | ] | |
| 802 | 806 | for url in urls: | |
@@ -810,7 +814,7 @@ def test_fetch_unsafe_url_allowed(self, rw_repo): | |||
| 810 | 814 | tmp_file = tmp_dir / "pwn" | |
| 811 | 815 | remote = rw_repo.remote("origin") | |
| 812 | 816 | urls = [ | |
| 813 | - f"ext::sh -c touch% {tmp_file}", | ||
| 817 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 814 | 818 | "fd::17/foo", | |
| 815 | 819 | ] | |
| 816 | 820 | for url in urls: | |
@@ -825,7 +829,7 @@ def test_fetch_unsafe_options(self, rw_repo): | |||
| 825 | 829 | remote = rw_repo.remote("origin") | |
| 826 | 830 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 827 | 831 | tmp_file = tmp_dir / "pwn" | |
| 828 | - unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | ||
| 832 | + unsafe_options = [{"upload-pack": "touch " + str(tmp_file)}] | ||
| 829 | 833 | for unsafe_option in unsafe_options: | |
| 830 | 834 | with self.assertRaises(UnsafeOptionError): | |
| 831 | 835 | remote.fetch(**unsafe_option) | |
@@ -836,12 +840,12 @@ def test_fetch_unsafe_options_allowed(self, rw_repo): | |||
| 836 | 840 | remote = rw_repo.remote("origin") | |
| 837 | 841 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 838 | 842 | tmp_file = tmp_dir / "pwn" | |
| 839 | - unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | ||
| 843 | + unsafe_options = [{"upload-pack": "touch " + str(tmp_file)}] | ||
| 840 | 844 | for unsafe_option in unsafe_options: | |
| 841 | 845 | # The options will be allowed, but the command will fail. | |
| 842 | 846 | assert not tmp_file.exists() | |
| 843 | 847 | with self.assertRaises(GitCommandError): | |
| 844 | - remote.fetch(**unsafe_option, allow_unsafe_options=True) | ||
| 848 | + remote.fetch(allow_unsafe_options=True, **unsafe_option) | ||
| 845 | 849 | assert tmp_file.exists() | |
| 846 | 850 | ||
| 847 | 851 | @with_rw_repo("HEAD") | |
@@ -850,7 +854,7 @@ def test_pull_unsafe_url(self, rw_repo): | |||
| 850 | 854 | tmp_file = tmp_dir / "pwn" | |
| 851 | 855 | remote = rw_repo.remote("origin") | |
| 852 | 856 | urls = [ | |
| 853 | - f"ext::sh -c touch% {tmp_file}", | ||
| 857 | + "ext::sh -c touch% " + str(tmp_file), | ||
| 854 | 858 | "fd::17/foo", | |
| 855 | 859 | ] | |
| 856 | 860 | for url in urls: | |
@@ -864,7 +868,7 @@ def test_pull_unsafe_url_allowed(self, rw_repo): | |||
| 864 | 868 | tmp_file = tmp_dir / "pwn" | |
| 865 | 869 | remote = rw_repo.remote("origin") | |
| 866 | 870 | urls = [ | |
| 867 | - f"ext::sh -c touch% {tmp_file}", | ||
| 871 | + "ext::sh -c touch% "+str(tmp_file), | ||
| 868 | 872 | "fd::17/foo", | |
| 869 | 873 | ] | |
| 870 | 874 | for url in urls: | |
@@ -879,7 +883,7 @@ def test_pull_unsafe_options(self, rw_repo): | |||
| 879 | 883 | remote = rw_repo.remote("origin") | |
| 880 | 884 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 881 | 885 | tmp_file = tmp_dir / "pwn" | |
| 882 | - unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | ||
| 886 | + unsafe_options = [{"upload-pack": "touch " + str(tmp_file)}] | ||
| 883 | 887 | for unsafe_option in unsafe_options: | |
| 884 | 888 | with self.assertRaises(UnsafeOptionError): | |
| 885 | 889 | remote.pull(**unsafe_option) | |
@@ -890,12 +894,12 @@ def test_pull_unsafe_options_allowed(self, rw_repo): | |||
| 890 | 894 | remote = rw_repo.remote("origin") | |
| 891 | 895 | tmp_dir = Path(tempfile.mkdtemp()) | |
| 892 | 896 | tmp_file = tmp_dir / "pwn" | |
| 893 | - unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | ||
| 897 | + unsafe_options = [{"upload-pack": "touch " + str(tmp_file)}] | ||
| 894 | 898 | for unsafe_option in unsafe_options: | |
| 895 | 899 | # The options will be allowed, but the command will fail. | |
| 896 | 900 | assert not tmp_file.exists() | |
| 897 | 901 | with self.assertRaises(GitCommandError): | |
| 898 | - remote.pull(**unsafe_option, allow_unsafe_options=True) | ||
| 902 | + remote.pull(allow_unsafe_options=True, **unsafe_option) | ||
| 899 | 903 | assert tmp_file.exists() | |
| 900 | 904 | ||
| 901 | 905 | @with_rw_repo("HEAD") | |
@@ -904,7 +908,7 @@ def test_push_unsafe_url(self, rw_repo): | |||
| 904 | 908 | tmp_file = tmp_dir / "pwn" | |
| 905 | 909 | remote = rw_repo.remote("origin") | |
| 906 | 910 | urls = [ | |
| 907 | - f"ext::sh -c touch% {tmp_file}", | ||
| 911 | + "ext::sh -c touch% " + str(tmp_file), | ||
| 908 | 912 | "fd::17/foo", | |
| 909 | 913 | ] | |
| 910 | 914 | for url in urls: | |
@@ -918,7 +922,7 @@ def test_push_unsafe_url_allowed(self, rw_repo): | |||
| 918 | 922 | tmp_file = tmp_dir / "pwn" | |
| 919 | 923 | remote = rw_repo.remote("origin") | |
| 920 | 924 | urls = [ | |
| 921 | - f"ext::sh -c touch% {tmp_file}", | ||
| 925 | + "ext::sh -c touch% " + str(tmp_file), | ||
| 922 | 926 | "fd::17/foo", | |
| 923 | 927 | ] | |
| 924 | 928 | for url in urls: | |
@@ -935,8 +939,8 @@ def test_push_unsafe_options(self, rw_repo): | |||
| 935 | 939 | tmp_file = tmp_dir / "pwn" | |
| 936 | 940 | unsafe_options = [ | |
| 937 | 941 | { | |
| 938 | - "receive-pack": f"touch {tmp_file}", | ||
| 939 | - "exec": f"touch {tmp_file}", | ||
| 942 | + "receive-pack": "touch " + str(tmp_file), | ||
| 943 | + "exec": "touch " + str(tmp_file), | ||
| 940 | 944 | } | |
| 941 | 945 | ] | |
| 942 | 946 | for unsafe_option in unsafe_options: | |
@@ -952,14 +956,14 @@ def test_push_unsafe_options_allowed(self, rw_repo): | |||
| 952 | 956 | tmp_file = tmp_dir / "pwn" | |
| 953 | 957 | unsafe_options = [ | |
| 954 | 958 | { | |
| 955 | - "receive-pack": f"touch {tmp_file}", | ||
| 956 | - "exec": f"touch {tmp_file}", | ||
| 959 | + "receive-pack": "touch " + str(tmp_file), | ||
| 960 | + "exec": "touch " + str(tmp_file), | ||
| 957 | 961 | } | |
| 958 | 962 | ] | |
| 959 | 963 | for unsafe_option in unsafe_options: | |
| 960 | 964 | # The options will be allowed, but the command will fail. | |
| 961 | 965 | assert not tmp_file.exists() | |
| 962 | 966 | with self.assertRaises(GitCommandError): | |
| 963 | - remote.push(**unsafe_option, allow_unsafe_options=True) | ||
| 967 | + remote.push(allow_unsafe_options=True, **unsafe_option) | ||
| 964 | 968 | assert tmp_file.exists() | |
| 965 | 969 | tmp_file.unlink() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments