Comments (16)
Ok - pushed out the npm release. Thanks to all for your help.
from ansi_up.
This is awesome!
I'm happy to add support for this. In progress...
from ansi_up.
Hi - quick update. Made some good progress over the last few days. More soon.
from ansi_up.
@LaKing - ok - code for testing is up on master. It required a lot of changes, but we were due for that anyways
I will be cleaning it up and revising the Readme tomorrow.
The big difference is that there is only ansi_to_html now.
Lmk if you have any comments on the functionality.
from ansi_up.
One more thing.
The URL part seems to rely on the protocol prefix, eg. http or https, thus relative links for example are not parsed, but left out empty. (no html at all)
from ansi_up.
@alech - thx, will investigate
from ansi_up.
@alech - ok, have time this week to work on all these issues. Updates soon.
from ansi_up.
Hi - I am not aware of this new tagging feature. Can you point me at where this is documented?
Which terminals support this?
If this is a new convention, that is great news. We could bring back the linkify code.
from ansi_up.
The best documentation found so far is this.
I'm using GNOME on Fedora, and I can confirm both of the above examples work.
JS example to create terminal links:
terminal-link (listed also on the bottom of chalk)
Sample is index.js
from
hyperlinker
from ansi_up.
Just an update. This is going to require a bit of work. However, that is ok. Now is a good time to clean up other parts as well.
from ansi_up.
Great!
This is my library of choice .) ...
.. let me know if I can help!
from ansi_up.
Works great!
Updated my code, and found no issues so far.
Thank you very much!
The only thing left is an update on the readme, and publishing it to npm. .)
from ansi_up.
Oopps, .. It works for the node way of creating links, but the bash way seems to left untouched as text.
from ansi_up.
Okay, I found a bug I think.
If the text part has a space, it breaks.
Problematic code "link 12" with a space
^[[34m^[]8;;http://example.com^Glink 12^[]8;;^G^[[0m
Working code "link:12" with no spaces
^[[34m^[]8;;http://example.com^Glink:12^[]8;;^G^[[0m
Both of these work in the terminal, but the problematic html output is
<span>]8;;http://example.com�link 12</span><span>]8;;�</span>
By the way, the alternative bash code for writing links similar way as the node code does (with \a)
## standard
echo -e '\e]8;;http://example.com\aThis is a link\e]8;;\a'
## colored
echo -e '\e[34m\e]8;;http://example.com\aThis is a link\e]8;;\a\e[0m'
from ansi_up.
The current implementation is prone to a DOM-based XSS attack. Since the URL parameter allows \x21-\x7e characters and the URL gets inserted into href
attribute without filtering, an attacker can close the a
tag and add (nearly) arbitrary HTML into the return value of process_hyperlink
. I would suggest actually parsing the URL with new URL
and then using the href
attribute of the result in order to be safe (plus the filtering of the schemes which is already in place and is a good feature could then be made more robust).
PoC:
var txt = ' \x1b]8;;http://example.com"></a><img/src="foo"onerror=alert(1)><pp\x1b\\.\x1b]8;;\x1b\\ ';
var ansi_up = new AnsiUp;
var html = ansi_up.ansi_to_html(txt);
var cdiv = document.getElementById("console");
cdiv.innerHTML = html;
from ansi_up.
I'm keeping this issue open for a few more days. Once I push the NPM, then I will close the issue.
from ansi_up.
Related Issues (20)
- iage
- Wrong DTS is used in package.json HOT 1
- remove file ansi_up.d.ts HOT 1
- Line feed failure HOT 6
- Relative links not allowed HOT 4
- How to live stream a log file? HOT 3
- Parse backspace character? HOT 8
- Document how to set properties HOT 2
- Works not in browser "Unexpected token 'export'" HOT 1
- Does rendering URL requires escape_for_html set to false? HOT 3
- OSC hyperlinks do not work with spaces HOT 3
- Escape for html stopped woking since 5.0.0 HOT 1
- A function to remove ansi color flag, for get plane log. HOT 1
- automatic links from http/https text HOT 2
- Inclusive design: change `whitelist` to `allowlist`? HOT 1
- Handle xterm normal/reset escape sequence HOT 5
- Handle carriage returns HOT 11
- Fix VERSION file HOT 1
- Lib brings in Npm 9 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansi_up.