cli-table / cli-table3

Pretty unicode tables for the command line
MIT License
534 stars 44 forks source link

[Bug] The table is broken, after adding url with exclamation mark #322

Open elaichenkov opened 1 year ago

elaichenkov commented 1 year ago

Description: The table is broken if providing a hyperlink with a shebang (#!).

Code snippet:

const Table = require('cli-table3');

const table = new Table();
const href = 'http://example.com/!';

table.push([{ content: 'Text Link', href }]);

console.log(table.toString());

Output:

┌───────────┐
│ │
└───────────┘
image
speedytwenty commented 1 year ago

Thanks for reporting this. I have reproduced the issue with tests. But I'm not sure of the appropriate way to escape. Encoding "!" as "%21" fixes the issue but I'm not sure if that would produce the expected result of the href unless the destination is explicitly decoding the url.

Is %21 the way to go? I don't know! Any ideas?

elaichenkov commented 1 year ago

It will definitely fix the issue with the table layout, but then the URL will not be correct. So, neither do I.

speedytwenty commented 1 year ago

I discovered that this issue seems to be related to the escape openings and closing between the link and the coloring of the table borders. It's tough to debug since the relevant output is non-visible (unicode) character codes.