← pod_r2_v1f

rich_3454

resolved RESOLVED PASS · 20 tool calls · 164 s · Textualize/rich

Task input

Fix [BUG] @ breaks highlighting in hyperlink #3327

## Type of changes

- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [x] Tests
- [ ] Other

## Checklist

- [ ] I've run the latest [black](https://github.com/psf/black) with default args on new code.
- [ ] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.

## Description
Fixed the bug [#3327](https://github.com/Textualize/rich/issues/3327).

Changes -
1. Added '@' in rich.highlighter:ReprHighlighter url regex pattern.
2. Added a test case in test_highlighter for the url with '@'.

## Note
Poetry installed black v22.12.0 and its formatting differs a bit from the latest version v24.8.0. Hence I've formatted with the prior to keep it consistent.

Tool calls (21)

#ToolArgumentsResult
1run_command
{
 "command": "grep -rn \"ReprHighlighter\" rich/highlighter.py"
}
{"status": "ok", "stdout": "rich/highlighter.py:80:class ReprHighlighter(RegexHighlighter):\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "rich/highlighter.py:80:class ReprHighlighter(RegexHighlighter):\n", "stderr": "", "exit_code": 0}
2run_command
{
 "command": "sed -n '80,150p' rich/highlighter.py"
}
{"status": "ok", "stdout": "class ReprHighlighter(RegexHighlighter):\n \"\"\"Highlights the text typically produced from ``__repr__`` methods.\"\"\"\n\n base_st
full
{"status": "ok", "stdout": "class ReprHighlighter(RegexHighlighter):\n    \"\"\"Highlights the text typically produced from ``__repr__`` methods.\"\"\"\n\n    base_style = \"repr.\"\n    highlights = [\n        r\"(?P<tag_start><)(?P<tag_name>[-\\w.:|]*)(?P<tag_contents>[\\w\\W]*)(?P<tag_end>>)\",\n        r'(?P<attrib_name>[\\w_]{1,50})=(?P<attrib_value>\"?[\\w_]+\"?)?',\n        r\"(?P<brace>[][{}()])\",\n        _combine_regex(\n            r\"(?P<ipv4>[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\",\n            r\"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})\",\n            r\"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\\.){3}[0-9A-Fa-f]{4})\",\n            r\"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\\.){2}[0-9A-Fa-f]{4})\",\n            r\"(?P<uuid>[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})\",\n            r\"(?P<call>[\\w.]*?)\\(\",\n            r\"\\b(?P<bool_true>True)\\b|\\b(?P<bool_false>False)\\b|\\b(?P<none>None)\\b\",\n            r\"(?P<ellipsis>\\.\\.\\.)\",\n            r\"(?P<number_complex>(?<!\\w)(?:\\-?[0-9]+\\.?[0-9]*(?:e[-+]?\\d+?)?)(?:[-+](?:[0-9]+\\.?[0-9]*(?:e[-+]?\\d+)?))?j)\",\n            r\"(?P<number>(?<!\\w)\\-?[0-9]+\\.?[0-9]*(e[-+]?\\d+?)?\\b|0x[0-9a-fA-F]*)\",\n            r\"(?P<path>\\B(/[-\\w._+]+)*\\/)(?P<filename>[-\\w._+]*)?\",\n            r\"(?<![\\\\\\w])(?P<str>b?'''.*?(?<!\\\\)'''|b?'.*?(?<!\\\\)'|b?\\\"\\\"\\\".*?(?<!\\\\)\\\"\\\"\\\"|b?\\\".*?(?<!\\\\)\\\")\",\n            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\",\n        ),\n    ]\n\n\nclass JSONHighlighter(RegexHighlighter):\n    \"\"\"Highlights JSON\"\"\"\n\n    # Captures the start and end of JSON strings, handling escaped quotes\n    JSON_STR = r\"(?<![\\\\\\w])(?P<str>b?\\\".*?(?<!\\\\)\\\")\"\n    JSON_WHITESPACE = {\" \", \"\\n\", \"\\r\", \"\\t\"}\
3run_command
{
 "command": "grep -rn \"test_highlighter\" tests/"
}
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
4run_command
{
 "command": "find tests -name \"*highlighter*\""
}
{"status": "ok", "stdout": "tests/test_highlighter.py\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "tests/test_highlighter.py\n", "stderr": "", "exit_code": 0}
5run_command
{
 "command": "grep -n \"ReprHighlighter\" tests/test_highlighter.py"
}
{"status": "ok", "stdout": "11: ReprHighlighter,\n161: \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n163: highlighter = ReprHighlighte
full
{"status": "ok", "stdout": "11:    ReprHighlighter,\n161:    \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n163:    highlighter = ReprHighlighter()\n", "stderr": "", "exit_code": 0}
6run_command
{
 "command": "sed -n '160,200p' tests/test_highlighter.py"
}
{"status": "ok", "stdout": "def test_highlight_regex(test: str, spans: List[Span]):\n \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n t
full
{"status": "ok", "stdout": "def test_highlight_regex(test: str, spans: List[Span]):\n    \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n    text = Text(test)\n    highlighter = ReprHighlighter()\n    highlighter.highlight(text)\n    print(text.spans)\n    assert text.spans == spans\n\n\ndef test_highlight_json_with_indent():\n    json_string = json.dumps({\"name\": \"apple\", \"count\": 1}, indent=4)\n    text = Text(json_string)\n    highlighter = JSONHighlighter()\n    highlighter.highlight(text)\n    assert text.spans == [\n        Span(0, 1, \"json.brace\"),\n        Span(6, 12, \"json.str\"),\n        Span(14, 21, \"json.str\"),\n        Span(27, 34, \"json.str\"),\n        Span(36, 37, \"json.number\"),\n        Span(38, 39, \"json.brace\"),\n        Span(6, 12, \"json.key\"),\n        Span(27, 34, \"json.key\"),\n    ]\n\n\ndef test_highlight_json_string_only():\n    json_string = '\"abc\"'\n    text = Text(json_string)\n    highlighter = JSONHighlighter()\n    highlighter.highlight(text)\n    assert text.spans == [Span(0, 5, \"json.str\")]\n\n\ndef test_highlight_json_empty_string_only():\n    json_string = '\"\"'\n    text = Text(json_string)\n    highlighter = JSONHighlighter()\n    highlighter.highlight(text)\n    assert text.spans == [Span(0, 2, \"json.str\")]\n\n", "stderr": "", "exit_code": 0}
7run_command
{
 "command": "grep -n \"test_highlight_regex\" tests/test_highlighter.py -B 5 -A 20"
}
{"status": "ok", "stdout": "155- (\"78351748-9b32-4e08-ad3e-7e9ff124d541\", [Span(0, 36, \"repr.uuid\")]),\n156-]\n157-\n158-\n159-@pytest.mark.parametrize(\"te
full
{"status": "ok", "stdout": "155-    (\"78351748-9b32-4e08-ad3e-7e9ff124d541\", [Span(0, 36, \"repr.uuid\")]),\n156-]\n157-\n158-\n159-@pytest.mark.parametrize(\"test, spans\", highlight_tests)\n160:def test_highlight_regex(test: str, spans: List[Span]):\n161-    \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n162-    text = Text(test)\n163-    highlighter = ReprHighlighter()\n164-    highlighter.highlight(text)\n165-    print(text.spans)\n166-    assert text.spans == spans\n167-\n168-\n169-def test_highlight_json_with_indent():\n170-    json_string = json.dumps({\"name\": \"apple\", \"count\": 1}, indent=4)\n171-    text = Text(json_string)\n172-    highlighter = JSONHighlighter()\n173-    highlighter.highlight(text)\n174-    assert text.spans == [\n175-        Span(0, 1, \"json.brace\"),\n176-        Span(6, 12, \"json.str\"),\n177-        Span(14, 21, \"json.str\"),\n178-        Span(27, 34, \"json.str\"),\n179-        Span(36, 37, \"json.number\"),\n180-        Span(38, 39, \"json.brace\"),\n", "stderr": "", "exit_code": 0}
8run_command
{
 "command": "sed -n '130,160p' tests/test_highlighter.py"
}
{"status": "ok", "stdout": " (\"ED-ED-ED-ED-ED-ED\", [Span(0, 17, \"repr.eui48\")]), # uppercase\n (\"Ed-Ed-Ed-Ed-Ed-Ed\", [Span(0, 17, \"repr.eui48\")]), # mix
full
{"status": "ok", "stdout": "    (\"ED-ED-ED-ED-ED-ED\", [Span(0, 17, \"repr.eui48\")]),  # uppercase\n    (\"Ed-Ed-Ed-Ed-Ed-Ed\", [Span(0, 17, \"repr.eui48\")]),  # mixed case\n    (\"0-00-1-01-2-02\", [Span(0, 14, \"repr.eui48\")]),  # dropped zero\n    (\" https://example.org \", [Span(1, 20, \"repr.url\")]),\n    (\" http://example.org \", [Span(1, 19, \"repr.url\")]),\n    (\" http://example.org/index.html \", [Span(1, 30, \"repr.url\")]),\n    (\" http://example.org/index.html#anchor \", [Span(1, 37, \"repr.url\")]),\n    (\n        \" http://example.org/index.html?param1=value1 \",\n        [\n            Span(31, 37, \"repr.attrib_name\"),\n            Span(38, 44, \"repr.attrib_value\"),\n            Span(1, 44, \"repr.url\"),\n        ],\n    ),\n    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n    (\"No place like 127.0.0.1\", [Span(14, 23, \"repr.ipv4\")]),\n    (\"''\", [Span(0, 2, \"repr.str\")]),\n    (\"'hello'\", [Span(0, 7, \"repr.str\")]),\n    (\"'''hello'''\", [Span(0, 11, \"repr.str\")]),\n    ('\"\"', [Span(0, 2, \"repr.str\")]),\n    ('\"hello\"', [Span(0, 7, \"repr.str\")]),\n    ('\"\"\"hello\"\"\"', [Span(0, 11, \"repr.str\")]),\n    (\"\\\\'foo'\", []),\n    (\"it's no 'string'\", [Span(8, 16, \"repr.str\")]),\n    (\"78351748-9b32-4e08-ad3e-7e9ff124d541\", [Span(0, 36, \"repr.uuid\")]),\n]\n\n\n@pytest.mark.parametrize(\"test, spans\", highlight_tests)\ndef test_highlight_regex(test: str, spans: List[Span]):\n", "stderr": "", "exit_code": 0}
9run_command
{
 "command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"rich/highlighter.py\"); s = p.read_text()\nold = r'r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\"'\nnew = r'r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)\"'\n# The old string in the file is actually: r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\"\n# But wait, the sed output showed: r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\"\n# Let me double check the exact line.\nPY\n"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
10run_command
{
 "command": "grep -n \"url\" rich/highlighter.py"
}
{"status": "ok", "stdout": "101: r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\",\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "101:            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\",\n", "stderr": "", "exit_code": 0}
11run_command
{
 "command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"rich/highlighter.py\"); s = p.read_text()\nold = '            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\",'\nnew = '            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)\",'\nassert s.count(old) == 1, (\"old text found this many times:\", s.count(old))\nt = s.replace(old, new); p.write_text(t)\nPY\n"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
12run_command
{
 "command": "sed -n '100,102p' rich/highlighter.py"
}
{"status": "ok", "stdout": " r\"(?<![\\\\\\w])(?P<str>b?'''.*?(?<!\\\\)'''|b?'.*?(?<!\\\\)'|b?\\\"\\\"\\\".*?(?<!\\\\)\\\"\\\"\\\"|b?\\\".*?(?<!\\\\)\\\")\",\n
full
{"status": "ok", "stdout": "            r\"(?<![\\\\\\w])(?P<str>b?'''.*?(?<!\\\\)'''|b?'.*?(?<!\\\\)'|b?\\\"\\\"\\\".*?(?<!\\\\)\\\"\\\"\\\"|b?\\\".*?(?<!\\\\)\\\")\",\n            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)\",\n        ),\n", "stderr": "", "exit_code": 0}
13run_command
{
 "command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"tests/test_highlighter.py\"); s = p.read_text()\n# Find where highlight_tests is defined.\n# Based on previous sed, it's a list of tuples.\n# I need to add a test case for url with '@'.\n# Let's find the line where the url tests are.\n# \" http://example.org/~folder \" is at line 142 approximately.\n# I'll add it after that.\n\n# Looking at the sed output:\n#    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n#    (\"No place like 127.0.0.1\", [Span(14, 23, \"repr.ipv4\")]),\n\n# I want to add:\n#    (\" http://user:pass@example.org \", [Span(1, 26, \"repr.url\")]),\n\n# Let's find the exact line to replace.\nold = '    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),'\nnew = '    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\\n    (\" http://user:pass@example.org \", [Span(1, 26, \"repr.url\")]),'\nassert s.count(old) == 1, (\"old text found this many times:\", s.count(old))\nt = s.replace(old, new); p.write_text(t)\nPY\n"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
14run_command
{
 "command": "sed -n '140,145p' tests/test_highlighter.py"
}
{"status": "ok", "stdout": " Span(31, 37, \"repr.attrib_name\"),\n Span(38, 44, \"repr.attrib_value\"),\n Span(1, 44, \"repr.url\"),\n ],\n ),\n (\" http://exam
full
{"status": "ok", "stdout": "            Span(31, 37, \"repr.attrib_name\"),\n            Span(38, 44, \"repr.attrib_value\"),\n            Span(1, 44, \"repr.url\"),\n        ],\n    ),\n    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n", "stderr": "", "exit_code": 0}
15run_command
{
 "command": "sed -n '145,150p' tests/test_highlighter.py"
}
{"status": "ok", "stdout": " (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n (\" http://user:pass@example.org \", [Span(1, 26, \"repr.url\")]
full
{"status": "ok", "stdout": "    (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n    (\" http://user:pass@example.org \", [Span(1, 26, \"repr.url\")]),\n    (\"No place like 127.0.0.1\", [Span(14, 23, \"repr.ipv4\")]),\n    (\"''\", [Span(0, 2, \"repr.str\")]),\n    (\"'hello'\", [Span(0, 7, \"repr.str\")]),\n    (\"'''hello'''\", [Span(0, 11, \"repr.str\")]),\n", "stderr": "", "exit_code": 0}
16run_command
{
 "command": "python3 -m pytest tests/test_highlighter.py -k test_highlight_regex"
}
{"status": "error", "error_type": "CommandError", "error_message": "============================= test session starts ==============================\nplatform d
full
{"status": "error", "error_type": "CommandError", "error_message": "============================= test session starts ==============================\nplatform darwin -- Python 3.13.15, pytest-8.3.4, pluggy-1.6.0\nrootdir: /private/workspace/tests\nconfigfile: pytest.ini\ncollected 83 items / 32 deselected / 51 selected\n\ntests/test_highlighter.py ........................................F..... [ 90%]\n.....                                                                    [100%]\n\n=================================== FAILURES ===================================\n_________ test_highlight_regex[ http://user:pass@example.org -spans40] _________\n\ntest = ' http://user:pass@example.org ', spans = [Span(1, 26, 'repr.url')]\n\n    @pytest.mark.parametrize(\"test, spans\", highlight_tests)\n    def test_highlight_regex(test: str, spans: List[Span]):\n        \"\"\"Tests for the regular expressions used in ReprHighlighter.\"\"\"\n        text = Text(test)\n        highlighter = ReprHighlighter()\n        highlighter.highlight(text)\n        print(text.spans)\n>       assert text.spans == spans\nE       AssertionError: assert [Span(1, 29, 'repr.url')] == [Span(1, 26, 'repr.url')]\nE         \nE         At index 0 diff: Span(1, 29, 'repr.url') != Span(1, 26, 'repr.url')\nE         Use -v to get more diff\n\ntests/test_highlighter.py:167: AssertionError\n----------------------------- Captured stdout call -----------------------------\n[Span(1, 29, 'repr.url')]\n=========================== short test summary info ============================\nFAILED tests/test_highlighter.py::test_highlight_regex[ http://user:pass@example.org -spans40]\n================= 1 failed, 50 passed, 32 deselected in 0.08s ==================\n", "details": {"stdout": "============================= test session starts ==============================\nplatform darwin -- Python 3.13.15, pytest-8.3.4, pluggy-1.6.0\nrootdir: /private/workspace/tests\nconfigfile: pytest.ini\ncollected 83 items / 32 deselected
17run_command
{
 "command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"tests/test_highlighter.py\"); s = p.read_text()\nold = '    (\" http://user:pass@example.org \", [Span(1, 26, \"repr.url\")]),'\nnew = '    (\" http://user:pass@example.org \", [Span(1, 29, \"repr.url\")]),'\nassert s.count(old) == 1, (\"old text found this many times:\", s.count(old))\nt = s.replace(old, new); p.write_text(t)\nPY\n"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
18run_command
{
 "command": "python3 -m pytest tests/test_highlighter.py -k test_highlight_regex"
}
{"status": "ok", "stdout": "============================= test session starts ==============================\nplatform darwin -- Python 3.13.15, pytest-8.3.4, p
full
{"status": "ok", "stdout": "============================= test session starts ==============================\nplatform darwin -- Python 3.13.15, pytest-8.3.4, pluggy-1.6.0\nrootdir: /private/workspace/tests\nconfigfile: pytest.ini\ncollected 83 items / 32 deselected / 51 selected\n\ntests/test_highlighter.py .............................................. [ 90%]\n.....                                                                    [100%]\n\n====================== 51 passed, 32 deselected in 0.07s =======================\n", "stderr": "", "exit_code": 0}
19run_command
{
 "command": "git diff"
}
{"status": "ok", "stdout": "diff --git a/rich/highlighter.py b/rich/highlighter.py\nindex 27714b25..e4c462e2 100644\n--- a/rich/highlighter.py\n+++ b/rich/highl
full
{"status": "ok", "stdout": "diff --git a/rich/highlighter.py b/rich/highlighter.py\nindex 27714b25..e4c462e2 100644\n--- a/rich/highlighter.py\n+++ b/rich/highlighter.py\n@@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter):\n             r\"(?P<number>(?<!\\w)\\-?[0-9]+\\.?[0-9]*(e[-+]?\\d+?)?\\b|0x[0-9a-fA-F]*)\",\n             r\"(?P<path>\\B(/[-\\w._+]+)*\\/)(?P<filename>[-\\w._+]*)?\",\n             r\"(?<![\\\\\\w])(?P<str>b?'''.*?(?<!\\\\)'''|b?'.*?(?<!\\\\)'|b?\\\"\\\"\\\".*?(?<!\\\\)\\\"\\\"\\\"|b?\\\".*?(?<!\\\\)\\\")\",\n-            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)\",\n+            r\"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)\",\n         ),\n     ]\n \ndiff --git a/tests/test_highlighter.py b/tests/test_highlighter.py\nindex 30851cf7..0bd52692 100644\n--- a/tests/test_highlighter.py\n+++ b/tests/test_highlighter.py\n@@ -143,6 +143,7 @@ highlight_tests = [\n         ],\n     ),\n     (\" http://example.org/~folder \", [Span(1, 27, \"repr.url\")]),\n+    (\" http://user:pass@example.org \", [Span(1, 29, \"repr.url\")]),\n     (\"No place like 127.0.0.1\", [Span(14, 23, \"repr.ipv4\")]),\n     (\"''\", [Span(0, 2, \"repr.str\")]),\n     (\"'hello'\", [Span(0, 7, \"repr.str\")]),\n", "stderr": "", "exit_code": 0}
20run_command
{
 "command": "git status"
}
{"status": "ok", "stdout": "On branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <
full
{"status": "ok", "stdout": "On branch main\nChanges not staged for commit:\n  (use \"git add <file>...\" to update what will be committed)\n  (use \"git restore <file>...\" to discard changes in working directory)\n\tmodified:   rich/highlighter.py\n\tmodified:   tests/test_highlighter.py\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n", "stderr": "", "exit_code": 0}
21submit_patch
{}
{"status": "ok", "patch_size": 1160, "files_changed": 2}
full
{"status": "ok", "patch_size": 1160, "files_changed": 2}

Patch

diff --git a/rich/highlighter.py b/rich/highlighter.py
index 27714b25..e4c462e2 100644
--- a/rich/highlighter.py
+++ b/rich/highlighter.py
@@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter):
             r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
             r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
             r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
-            r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)",
+            r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)",
         ),
     ]
 
diff --git a/tests/test_highlighter.py b/tests/test_highlighter.py
index 30851cf7..0bd52692 100644
--- a/tests/test_highlighter.py
+++ b/tests/test_highlighter.py
@@ -143,6 +143,7 @@ highlight_tests = [
         ],
     ),
     (" http://example.org/~folder ", [Span(1, 27, "repr.url")]),
+    (" http://user:pass@example.org ", [Span(1, 29, "repr.url")]),
     ("No place like 127.0.0.1", [Span(14, 23, "repr.ipv4")]),
     ("''", [Span(0, 2, "repr.str")]),
     ("'hello'", [Span(0, 7, "repr.str")]),

Test output

show
........................................................................ [ 86%]
...........                                                              [100%]
83 passed in 0.07s