Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def escape_empty(val):
|
# terminal hyperlinks
{_osc}8; # OSC opening
(\w+=\w+:?)* # key=value params list (submatch 2)
(\w+=\w+(?::\w+=\w+)*:?)? # key=value params list (submatch 2)
; # delimiter
([^{_esc}]+) # URI - anything but ESC (submatch 3)
{_st} # ST
Expand Down
12 changes: 12 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Regression tests."""

import time

from tabulate import DataRow, Line, TableFormat, tabulate

from common import assert_equal, skip
Expand Down Expand Up @@ -598,3 +600,13 @@ def test_github_escape_pipe_character():
result = tabulate([["foo|bar"]], headers=("spam|eggs",), tablefmt="github")
expected = "| spam\\|eggs |\n|:------------|\n| foo\\|bar |"
assert_equal(expected, result)


def test_osc8_link_params_no_catastrophic_backtracking():
"Regression: unterminated OSC 8 link params must not backtrack exponentially"
cell = "\x1b]8;a=" + "aaaa=" * 16
start = time.perf_counter()
result = tabulate([[cell]], tablefmt="plain")
elapsed = time.perf_counter() - start
assert_equal(cell, result)
assert elapsed < 1.0