fix: escape rich markup in ls table cells
This commit is contained in:
parent
921f06b4fa
commit
3a9f3a2fcd
2 changed files with 11 additions and 1 deletions
|
|
@ -79,7 +79,8 @@ def mktable(query: str, index: dict, filter=None, trunc_len: int=25):
|
|||
else:
|
||||
elements.append(None)
|
||||
|
||||
table.add_row(*elements)
|
||||
# Cells are read as rich markup, so [brackets] in names and notes need escaping
|
||||
table.add_row(*[escape(element) if element else element for element in elements])
|
||||
console.print(table)
|
||||
else:
|
||||
console.print(f":thinking_face: [red]No results found for [white]{query}")
|
||||
|
|
|
|||
|
|
@ -170,3 +170,12 @@ def test_cmd_user_errors_exit_with_1(cwd, monkeypatch, capsys):
|
|||
main()
|
||||
assert exit.value.code == 1
|
||||
assert "File missing.mp3 doesn't exist." in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_cmd_list_shows_square_brackets(cwd, monkeypatch, capsys):
|
||||
(cwd / 'a [demo].mp3').touch()
|
||||
OrvaniTag().add('a [demo].mp3', '#lofi', 'note', '[with]', 'brackets')
|
||||
monkeypatch.setattr(sys, 'argv', ['otag', 'ls', '#lofi'])
|
||||
main()
|
||||
out = capsys.readouterr().out
|
||||
assert 'a [demo].mp3' in out and '[with]' in out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue