Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd22c40b

Browse files
authored
Merge pull request#467 from gitpython-developers/fix-dont-choke-on-invalid-unicode-paths
Don't choke on (legitimately) invalidly encoded Unicode paths
2 parents4510b3c +200d3c6 commitd22c40b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

‎git/diff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,15 @@ def _index_from_patch_format(cls, repo, stream):
404404
a_mode=old_modeordeleted_file_modeor (a_pathand (b_modeornew_modeornew_file_mode))
405405
b_mode=b_modeornew_modeornew_file_modeor (b_pathanda_mode)
406406
index.append(Diff(repo,
407-
a_pathanda_path.decode(defenc),
408-
b_pathandb_path.decode(defenc),
407+
a_pathanda_path.decode(defenc,'replace'),
408+
b_pathandb_path.decode(defenc,'replace'),
409409
a_blob_idanda_blob_id.decode(defenc),
410410
b_blob_idandb_blob_id.decode(defenc),
411411
a_modeanda_mode.decode(defenc),
412412
b_modeandb_mode.decode(defenc),
413413
new_file,deleted_file,
414-
rename_fromandrename_from.decode(defenc),
415-
rename_toandrename_to.decode(defenc),
414+
rename_fromandrename_from.decode(defenc,'replace'),
415+
rename_toandrename_to.decode(defenc,'replace'),
416416
None))
417417

418418
previous_header=header

‎git/test/fixtures/diff_patch_unsafe_paths

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94
6868
+++ "b/path/\360\237\222\251.txt"
6969
@@ -0,0 +1 @@
7070
+dummy content
71+
diff --git "a/path/\200-invalid-unicode-path.txt" "b/path/\200-invalid-unicode-path.txt"
72+
new file mode 100644
73+
index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
74+
--- /dev/null
75+
+++ "b/path/\200-invalid-unicode-path.txt"
76+
@@ -0,0 +1 @@
77+
+dummy content
7178
diff --git a/a/with spaces b/b/with some spaces
7279
similarity index 100%
7380
rename from a/with spaces

‎git/test/test_diff.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,17 @@ def test_diff_unsafe_paths(self):
162162
self.assertEqual(res[7].b_path,u'path/with-question-mark?')
163163
self.assertEqual(res[8].b_path,u'path/¯\\_(ツ)_|¯')
164164
self.assertEqual(res[9].b_path,u'path/💩.txt')
165+
self.assertEqual(res[10].b_path,u'path/�-invalid-unicode-path.txt')
165166

166167
# The "Moves"
167168
# NOTE: The path prefixes a/ and b/ here are legit! We're actually
168169
# verifying that it's not "a/a/" that shows up, see the fixture data.
169-
self.assertEqual(res[10].a_path,u'a/with spaces')# NOTE: path a/ here legit!
170-
self.assertEqual(res[10].b_path,u'b/with some spaces')# NOTE: path b/ here legit!
171-
self.assertEqual(res[11].a_path,u'a/ending in a space ')
172-
self.assertEqual(res[11].b_path,u'b/ending with space ')
173-
self.assertEqual(res[12].a_path,u'a/"with-quotes"')
174-
self.assertEqual(res[12].b_path,u'b/"with even more quotes"')
170+
self.assertEqual(res[11].a_path,u'a/with spaces')# NOTE: path a/ here legit!
171+
self.assertEqual(res[11].b_path,u'b/with some spaces')# NOTE: path b/ here legit!
172+
self.assertEqual(res[12].a_path,u'a/ending in a space ')
173+
self.assertEqual(res[12].b_path,u'b/ending with space ')
174+
self.assertEqual(res[13].a_path,u'a/"with-quotes"')
175+
self.assertEqual(res[13].b_path,u'b/"with even more quotes"')
175176

176177
deftest_diff_patch_format(self):
177178
# test all of the 'old' format diffs for completness - it should at least

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp