# HG changeset patch # User Daniel Dourvaris # Date 2019-08-26 19:49:06 # Node ID 4ef42a9b44198df6e8edc4833aa07fe9442fb1c9 # Parent 01c5c83d419ccf6f0dd38ca40b86141329661d11 diffs: handle paths with quotes in diffs. diff --git a/rhodecode/lib/vcs/backends/git/diff.py b/rhodecode/lib/vcs/backends/git/diff.py --- a/rhodecode/lib/vcs/backends/git/diff.py +++ b/rhodecode/lib/vcs/backends/git/diff.py @@ -44,6 +44,6 @@ class GitDiff(base.Diff): (?:^index[ ](?P[0-9A-Fa-f]+) \.\.(?P[0-9A-Fa-f]+)[ ]?(?P.+)?(?:\n|$))? (?:^(?PGIT[ ]binary[ ]patch)(?:\n|$))? - (?:^---[ ](a/(?P.+)|/dev/null)(?:\n|$))? - (?:^\+\+\+[ ](b/(?P.+)|/dev/null)(?:\n|$))? + (?:^---[ ]("?a/(?P.+)|/dev/null)(?:\n|$))? + (?:^\+\+\+[ ]("?b/(?P.+)|/dev/null)(?:\n|$))? """, re.VERBOSE | re.MULTILINE) diff --git a/rhodecode/lib/vcs/backends/hg/diff.py b/rhodecode/lib/vcs/backends/hg/diff.py --- a/rhodecode/lib/vcs/backends/hg/diff.py +++ b/rhodecode/lib/vcs/backends/hg/diff.py @@ -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[0-9A-Fa-f]+) \.\.(?P[0-9A-Fa-f]+)[ ]?(?P.+)?(?:\n|$))? (?:^(?PGIT[ ]binary[ ]patch)(?:\n|$))? - (?:^---[ ](a/(?P.+)|/dev/null)(?:\n|$))? - (?:^\+\+\+[ ](b/(?P.+)|/dev/null)(?:\n|$))? + (?:^---[ ]("?a/(?P.+)|/dev/null)(?:\n|$))? + (?:^\+\+\+[ ]("?b/(?P.+)|/dev/null)(?:\n|$))? """, re.VERBOSE | re.MULTILINE) diff --git a/rhodecode/lib/vcs/backends/svn/diff.py b/rhodecode/lib/vcs/backends/svn/diff.py --- a/rhodecode/lib/vcs/backends/svn/diff.py +++ b/rhodecode/lib/vcs/backends/svn/diff.py @@ -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[0-9A-Fa-f]+) \.\.(?P[0-9A-Fa-f]+)[ ]?(?P.+)?(?:\n|$))? (?:^(?PGIT[ ]binary[ ]patch)(?:\n|$))? - (?:^---[ ](a/(?P.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))? - (?:^\+\+\+[ ](b/(?P.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))? + (?:^---[ ]("?a/(?P.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))? + (?:^\+\+\+[ ]("?b/(?P.+)|/dev/null)\t\(revision[ ]\d+\)(?:\n|$))? """, re.VERBOSE | re.MULTILINE) diff --git a/rhodecode/tests/fixtures/git_diff_js_chars.diff b/rhodecode/tests/fixtures/git_diff_js_chars.diff new file mode 100644 --- /dev/null +++ b/rhodecode/tests/fixtures/git_diff_js_chars.diff @@ -0,0 +1,7 @@ +diff --git "a/\">/\">.txt" "b/\">/\">.txt" +index e69de29..8eb97de 100644 +--- "a/\">/\">.txt" ++++ "b/\">/\">.txt" +@@ -0,0 +1 @@ ++Ehlo eglo +\ No newline at end of file diff --git a/rhodecode/tests/lib/test_diffs.py b/rhodecode/tests/lib/test_diffs.py --- a/rhodecode/tests/lib/test_diffs.py +++ b/rhodecode/tests/lib/test_diffs.py @@ -343,6 +343,14 @@ DIFF_FIXTURES = [ 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}) ]), ('git', + 'git_diff_js_chars.diff', + [('\\">/\\">.txt', 'M', + {'added': 1, + 'deleted': 0, + 'binary': False, + 'ops': {MOD_FILENODE: 'modified file'}}) + ]), + ('git', 'git_diff_rename_file.diff', [('file.xls', 'M', {'added': 0,