Socket
Socket
Sign inDemoInstall

ansi_up

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi_up - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

26

ansi_up.js

@@ -37,3 +37,3 @@ /* ansi_up.js

function AnsiUp() {
this.VERSION = "5.1.0";
this.VERSION = "5.2.0";
this.setup_palettes();

@@ -47,2 +47,3 @@ this._use_classes = false;

this._url_whitelist = { 'http': 1, 'https': 1 };
this._escape_html = true;
}

@@ -69,2 +70,12 @@ Object.defineProperty(AnsiUp.prototype, "use_classes", {

});
Object.defineProperty(AnsiUp.prototype, "escape_html", {
get: function () {
return this._escape_html;
},
set: function (arg) {
this._escape_html = arg;
},
enumerable: false,
configurable: true
});
AnsiUp.prototype.setup_palettes = function () {

@@ -117,2 +128,4 @@ var _this = this;

AnsiUp.prototype.escape_txt_for_html = function (txt) {
if (!this._escape_html)
return txt;
return txt.replace(/[&<>"']/gm, function (str) {

@@ -158,3 +171,3 @@ if (str === "&")

if (pos == 0) {
if (len == 1) {
if (len < 3) {
pkt.kind = PacketKind.Incomplete;

@@ -164,3 +177,3 @@ return pkt;

var next_char = this._buffer.charAt(1);
if ((next_char != '[') && (next_char != ']')) {
if ((next_char != '[') && (next_char != ']') && (next_char != '(')) {
pkt.kind = PacketKind.ESC;

@@ -195,3 +208,3 @@ pkt.text = this._buffer.slice(0, 1);

}
if (next_char == ']') {
else if (next_char == ']') {
if (len < 4) {

@@ -255,2 +268,7 @@ pkt.kind = PacketKind.Incomplete;

}
else if (next_char == '(') {
pkt.kind = PacketKind.Unknown;
this._buffer = this._buffer.slice(3);
return pkt;
}
}

@@ -257,0 +275,0 @@ };

@@ -55,3 +55,3 @@ /* ansi_up.js

{
VERSION = "5.1.0";
VERSION = "5.2.0";

@@ -80,2 +80,3 @@ //

private _url_whitelist:{};
private _escape_html:boolean;

@@ -98,2 +99,3 @@ private _buffer:string;

this._url_whitelist = { 'http':1, 'https':1 };
this._escape_html = true;
}

@@ -121,3 +123,13 @@

set escape_html(arg:boolean)
{
this._escape_html = arg;
}
get escape_html():boolean
{
return this._escape_html;
}
private setup_palettes():void

@@ -183,2 +195,4 @@ {

{
if (!this._escape_html)
return txt;
return txt.replace(/[&<>"']/gm, (str) => {

@@ -234,4 +248,5 @@ if (str === "&") return "&amp;";

{
if (len == 1) // Lone ESC in Buffer, We don't know yet
// All of the sequences typically need at least 3 characters
// So, wait until we have at least that many
if (len < 3)
{

@@ -245,4 +260,4 @@ pkt.kind = PacketKind.Incomplete;

// We treat this as a single ESC
// Which effecitvely shows
if ((next_char != '[') && (next_char != ']')) // DeMorgan
// No transformation
if ((next_char != '[') && (next_char != ']') && (next_char != '('))
{

@@ -343,3 +358,3 @@ pkt.kind = PacketKind.ESC;

}
else
// OSC CHECK

@@ -518,2 +533,14 @@ if (next_char == ']')

}
else
// Other ESC CHECK
if (next_char == '(')
{
// This specifies the character set, which
// should just be ignored
// We have at least 3, so drop the sequence
pkt.kind = PacketKind.Unknown;
this._buffer = this._buffer.slice(3);
return pkt;
}
}

@@ -520,0 +547,0 @@ }

@@ -41,2 +41,3 @@ export interface AU_Color {

private _url_whitelist;
private _escape_html;
private _buffer;

@@ -48,2 +49,4 @@ constructor();

get url_whitelist(): {};
set escape_html(arg: boolean);
get escape_html(): boolean;
private setup_palettes;

@@ -50,0 +53,0 @@ private escape_txt_for_html;

9

package.json
{
"name": "ansi_up",
"version": "5.1.0",
"version": "5.2.0",
"description": "Convert ansi sequences in strings to colorful HTML",

@@ -28,6 +28,9 @@ "keywords": [

"devDependencies": {
"mocha": "*",
"mocha": "^10.2.0",
"should": "*",
"typescript": "^3.0"
"typescript": "^3.9.10"
},
"dependencies": {
"npm": "^9.6.3"
}
}

@@ -123,2 +123,7 @@ # ansi_up.js

#### escape_html
(default: true)
By default, HTML's reserved characters `& < > " '` are replaced with <a href="https://www.w3schools.com/html/html_entities.asp">HTML entities</a> to make them appear as literal characters in your application, rather than being interpreted as HTML structure. If you prefer keeping HTML's reserved characters untouched, you can set this to false.
#### use_classes

@@ -125,0 +130,0 @@ (default: false)

@@ -753,2 +753,14 @@ var AU = require('../ansi_up');

describe('ignore controls beginning with ESC', function () {
it('Designate G0 Character Set (UK)', function () {
var start = "foo\033(Abar";
var au = new AnsiUp();
var l = au.ansi_to_html(start);
l.should.eql('foobar');
});
});
describe('buffering situations', function () {

@@ -755,0 +767,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc