diffs: handle paths with quotes in diffs.

This commit is contained in:
Daniel Dourvaris 2019-08-26 21:49:06 +02:00
parent 21fb4a7124
commit ff0c66acf2
5 changed files with 22 additions and 8 deletions

View file

@ -44,6 +44,6 @@ class GitDiff(base.Diff):
(?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
\.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
(?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))?
(?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))?
(?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
(?:^---[ ]("?a/(?P<a_file>.+)|/dev/null)(?:\n|$))?
(?:^\+\+\+[ ]("?b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
""", re.VERBOSE | re.MULTILINE)

View file

@ -19,7 +19,7 @@
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
GIT diff module
HG diff module
"""
import re
@ -44,6 +44,6 @@ class MercurialDiff(base.Diff):
(?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
\.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
(?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))?
(?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))?
(?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
(?:^---[ ]("?a/(?P<a_file>.+)|/dev/null)(?:\n|$))?
(?:^\+\+\+[ ]("?b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
""", re.VERBOSE | re.MULTILINE)

View file

@ -18,7 +18,6 @@
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
SVN diff module
"""
@ -47,6 +46,6 @@ class SubversionDiff(base.Diff):
(?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
\.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
(?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))?
(?:^---[ ](a/(?P<a_file>.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))?
(?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))?
(?:^---[ ]("?a/(?P<a_file>.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))?
(?:^\+\+\+[ ]("?b/(?P<b_file>.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))?
""", re.VERBOSE | re.MULTILINE)

View file

@ -0,0 +1,7 @@
diff --git "a/\"><img src=x onerror=prompt(0)>/\"><img src=x onerror=prompt(1)>.txt" "b/\"><img src=x onerror=prompt(0)>/\"><img src=x onerror=prompt(1)>.txt"
index e69de29..8eb97de 100644
--- "a/\"><img src=x onerror=prompt(0)>/\"><img src=x onerror=prompt(1)>.txt"
+++ "b/\"><img src=x onerror=prompt(0)>/\"><img src=x onerror=prompt(1)>.txt"
@@ -0,0 +1 @@
+Ehlo eglo
\ No newline at end of file

View file

@ -342,6 +342,14 @@ DIFF_FIXTURES = [
'binary': True,
'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}})
]),
('git',
'git_diff_js_chars.diff',
[('\\"><img src=x onerror=prompt(0)>/\\"><img src=x onerror=prompt(1)>.txt', 'M',
{'added': 1,
'deleted': 0,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}})
]),
('git',
'git_diff_rename_file.diff',
[('file.xls', 'M',