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

Commit6ef2739

Browse files
committed
fix(RemoteProgress): improve message sanitization
Don't allow `, ` prefixes or suffixes in messages.Fixes#438
1 parentb6a6a10 commit6ef2739

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

‎doc/source/changes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Changelog
77

88
* Fix: bug in ``git-blame --incremental`` output parser that broken when
99
commit messages contained ``\r`` characters
10-
* Fix: progress handler exceptions are not caught anymore, which would
11-
usually just hide bugspreviously.
12-
* Fix: The ``Git.execute`` method will now redirect ``stdout`` to
13-
``devnull`` if ``with_stdout`` is false, which is theintended behaviour
14-
based ontheparameter's documentation.
10+
* Fix: progress handler exceptions are not caught anymore, which would usually just hide bugs
11+
previously.
12+
* Fix: The `Git.execute` method will now redirect `stdout` to `devnull` if `with_stdout` is false,
13+
which is the intended behaviour based on theparameter's documentation.
14+
* Fix: `RemoteProgress` will now stripthe', ' prefix or suffix from messages.
1515

1616
2.0.2 - Fixes
1717
=============

‎git/test/test_remote.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ def update(self, op_code, cur_count, max_count=None, message=''):
6262
# check each stage only comes once
6363
op_id=op_code&self.OP_MASK
6464
assertop_idin (self.COUNTING,self.COMPRESSING,self.WRITING)
65+
66+
ifop_code&self.WRITING>0:
67+
ifop_code&self.BEGIN>0:
68+
assertnotmessage,'should not have message when remote begins writing'
69+
elifop_code&self.END>0:
70+
assertmessage
71+
assertnotmessage.startswith(', '),"Sanitize progress messages: '%s'"%message
72+
assertnotmessage.endswith(', '),"Sanitize progress messages: '%s'"%message
6573

6674
self._stages_per_op.setdefault(op_id,0)
6775
self._stages_per_op[op_id]=self._stages_per_op[op_id]| (op_code&self.STAGE_MASK)

‎git/util.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,16 @@ class RemoteProgress(object):
171171
STAGE_MASK=BEGIN|END
172172
OP_MASK=~STAGE_MASK
173173

174+
DONE_TOKEN='done.'
175+
TOKEN_SEPARATOR=', '
176+
174177
__slots__= ("_cur_line","_seen_ops")
175-
re_op_absolute=re.compile("(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
176-
re_op_relative=re.compile("(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
178+
re_op_absolute=re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
179+
re_op_relative=re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
177180

178181
def__init__(self):
179182
self._seen_ops=list()
183+
self._cur_line=None
180184

181185
def_parse_progress_line(self,line):
182186
"""Parse progress information from the given line as retrieved by git-push
@@ -257,11 +261,11 @@ def _parse_progress_line(self, line):
257261
# END message handling
258262

259263
message=message.strip()
260-
done_token=', done.'
261-
ifmessage.endswith(done_token):
264+
ifmessage.endswith(self.DONE_TOKEN):
262265
op_code|=self.END
263-
message=message[:-len(done_token)]
266+
message=message[:-len(self.DONE_TOKEN)]
264267
# END end message handling
268+
message=message.strip(self.TOKEN_SEPARATOR)
265269

266270
self.update(op_code,
267271
cur_countandfloat(cur_count),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp