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

Add test case as example of Git commit with invalid data#456

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 2 commits intomasterfromfix-for-invalid-data-in-commits
May 30, 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
6 changes: 3 additions & 3 deletionsgit/objects/commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -501,14 +501,14 @@ def _deserialize(self, stream):

try:
self.author, self.authored_date, self.author_tz_offset = \
parse_actor_and_date(author_line.decode(self.encoding))
parse_actor_and_date(author_line.decode(self.encoding, errors='replace'))
except UnicodeDecodeError:
log.error("Failed to decode author line '%s' using encoding %s", author_line, self.encoding,
exc_info=True)

try:
self.committer, self.committed_date, self.committer_tz_offset = \
parse_actor_and_date(committer_line.decode(self.encoding))
parse_actor_and_date(committer_line.decode(self.encoding, errors='replace'))
except UnicodeDecodeError:
log.error("Failed to decode committer line '%s' using encoding %s", committer_line, self.encoding,
exc_info=True)
Expand All@@ -518,7 +518,7 @@ def _deserialize(self, stream):
# The end of our message stream is marked with a newline that we strip
self.message = stream.read()
try:
self.message = self.message.decode(self.encoding)
self.message = self.message.decode(self.encoding, errors='replace')
except UnicodeDecodeError:
log.error("Failed to decode message '%s' using encoding %s", self.message, self.encoding, exc_info=True)
# END exception handling
Expand Down
6 changes: 6 additions & 0 deletionsgit/test/fixtures/commit_invalid_data
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
tree 9f1a495d7d9692d24f5caedaa89f5c2c32d59368
parent 492ace2ffce0e426ebeb55e364e987bcf024dd3b
author E.Azer Ko�o�o�oculu <azer@kodfabrik.com> 1306710073 +0300
committer E.Azer Ko�o�o�oculu <azer@kodfabrik.com> 1306710073 +0300

add environjs
7 changes: 7 additions & 0 deletionsgit/test/test_commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -306,6 +306,13 @@ def test_serialization_unicode_support(self):
# it appears
cmt.author.__repr__()

def test_invalid_commit(self):
cmt = self.rorepo.commit()
cmt._deserialize(open(fixture_path('commit_invalid_data'), 'rb'))

assert cmt.author.name == u'E.Azer Ko�o�o�oculu', cmt.author.name
assert cmt.author.email == 'azer@kodfabrik.com', cmt.author.email

def test_gpgsig(self):
cmt = self.rorepo.commit()
cmt._deserialize(open(fixture_path('commit_with_gpgsig'), 'rb'))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp