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

Don't choke on (legitimately) invalidly encoded Unicode paths#467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 1 commit intomasterfromfix-dont-choke-on-invalid-unicode-paths
Jun 14, 2016
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletionsgit/diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -404,15 +404,15 @@ def _index_from_patch_format(cls, repo, stream):
a_mode = old_mode or deleted_file_mode or (a_path and (b_mode or new_mode or new_file_mode))
b_mode = b_mode or new_mode or new_file_mode or (b_path and a_mode)
index.append(Diff(repo,
a_path and a_path.decode(defenc),
b_path and b_path.decode(defenc),
a_path and a_path.decode(defenc, 'replace'),
b_path and b_path.decode(defenc, 'replace'),
a_blob_id and a_blob_id.decode(defenc),
b_blob_id and b_blob_id.decode(defenc),
a_mode and a_mode.decode(defenc),
b_mode and b_mode.decode(defenc),
new_file, deleted_file,
rename_from and rename_from.decode(defenc),
rename_to and rename_to.decode(defenc),
rename_from and rename_from.decode(defenc, 'replace'),
rename_to and rename_to.decode(defenc, 'replace'),
None))

previous_header = header
Expand Down
7 changes: 7 additions & 0 deletionsgit/test/fixtures/diff_patch_unsafe_paths
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,13 @@ index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94
+++ "b/path/\360\237\222\251.txt"
@@ -0,0 +1 @@
+dummy content
diff --git "a/path/\200-invalid-unicode-path.txt" "b/path/\200-invalid-unicode-path.txt"
new file mode 100644
index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
--- /dev/null
+++ "b/path/\200-invalid-unicode-path.txt"
@@ -0,0 +1 @@
+dummy content
diff --git a/a/with spaces b/b/with some spaces
similarity index 100%
rename from a/with spaces
Expand Down
13 changes: 7 additions & 6 deletionsgit/test/test_diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -162,16 +162,17 @@ def test_diff_unsafe_paths(self):
self.assertEqual(res[7].b_path, u'path/with-question-mark?')
self.assertEqual(res[8].b_path, u'path/¯\\_(ツ)_|¯')
self.assertEqual(res[9].b_path, u'path/💩.txt')
self.assertEqual(res[10].b_path, u'path/�-invalid-unicode-path.txt')

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

def test_diff_patch_format(self):
# test all of the 'old' format diffs for completness - it should at least
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp