Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating regex pattern to handle unicode whitespaces. #1853

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class FetchInfo(IterableObj):
ERROR,
) = [1 << x for x in range(8)]

_re_fetch_result = re.compile(r"^\s*(.) (\[[\w\s\.$@]+\]|[\w\.$@]+)\s+(.+) -> ([^\s]+)( \(.*\)?$)?")
_re_fetch_result = re.compile(r"^ *(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?")

_flag_map: Dict[flagKeyLiteral, int] = {
"!": ERROR,
Expand Down
15 changes: 15 additions & 0 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,21 @@ def test_push_unsafe_options_allowed(self, rw_repo):
assert tmp_file.exists()
tmp_file.unlink()

@with_rw_and_rw_remote_repo("0.1.6")
def test_fetch_unsafe_branch_name(self, rw_repo, remote_repo):
# Create branch with a name containing a NBSP
bad_branch_name = f"branch_with_{chr(160)}_nbsp"
Head.create(remote_repo, bad_branch_name)

# Fetch and get branches
remote = rw_repo.remote("origin")
branches = remote.fetch()

# Test for truncated branch name in branches
assert f"origin/{bad_branch_name}" in [b.name for b in branches]

# Cleanup branch
Head.delete(remote_repo, bad_branch_name)

class TestTimeouts(TestBase):
@with_rw_repo("HEAD", bare=False)
Expand Down
Loading