ansi_stream 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f3e27b64b52f52548995562513d0a00254625c
|
4
|
+
data.tar.gz: 430f37a7a11f7b9192ffa5370c852b4c399ed8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 373361dc71facf4e3d51f6554d3a3cebb17174ad0c15d0f53f85acf74879de9ba30522de824ccc1a361ada452293b60e8714e3e8253f2bb107c8e6002e6b721c
|
7
|
+
data.tar.gz: eb0e68dcf25828b9372aac543d515fcce23df7106e5b1da346b9c41c84f3439f09de6bd3977ae9cc11d56d42260314f1c480a911171dc26b1171686dcb76a5e0
|
data/lib/ansi_stream/version.rb
CHANGED
@@ -12,6 +12,11 @@ describe "AnsiStream", ->
|
|
12
12
|
expectClass(span, 'ansi-foreground-default')
|
13
13
|
expect(span.innerHTML).toBe('mkdir')
|
14
14
|
|
15
|
+
|
16
|
+
it 'is not subject to XSS', ->
|
17
|
+
span = stream.process("echo <script>alert('pwned!')").childNodes[0]
|
18
|
+
expect(span.innerHTML).toBe("echo <script>alert('pwned!')")
|
19
|
+
|
15
20
|
it 'returns colorized spans if there is an foreground color code', ->
|
16
21
|
expectClass(stream.process('\u001B[31mtoto').childNodes[0], 'ansi-foreground-red')
|
17
22
|
|
@@ -36,3 +41,6 @@ describe "AnsiStream", ->
|
|
36
41
|
spans = stream.process("\u001B[4mtoto\u001B[24mtiti")
|
37
42
|
expectClass(spans.childNodes[0], 'ansi-underline')
|
38
43
|
expect(spans.childNodes[1].className.indexOf('ansi-underline')).toBe(-1)
|
44
|
+
|
45
|
+
it 'can strip ANSI codes from a string', ->
|
46
|
+
expect(AnsiStream.strip('\u001B[31mtoto')).toBe('toto')
|
@@ -1,4 +1,17 @@
|
|
1
1
|
class @AnsiStream
|
2
|
+
ANSI_CODE = ///
|
3
|
+
((\u001b\[)|\u009b)
|
4
|
+
(
|
5
|
+
\d{0,3}
|
6
|
+
(;\d{0,3})*
|
7
|
+
[A-M|f-m]
|
8
|
+
)
|
9
|
+
|\u001b[A-M]
|
10
|
+
///g
|
11
|
+
|
12
|
+
@strip: (text) ->
|
13
|
+
text.replace(ANSI_CODE, '')
|
14
|
+
|
2
15
|
constructor: ->
|
3
16
|
@style = new AnsiStyle()
|
4
17
|
@span = new AnsiSpan()
|
@@ -81,6 +94,6 @@ class AnsiStyle
|
|
81
94
|
class AnsiSpan
|
82
95
|
create: (text, style) ->
|
83
96
|
span = document.createElement('span')
|
84
|
-
span.
|
97
|
+
span.textContent = text
|
85
98
|
span.className = style.toClass()
|
86
99
|
span
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansi_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Malette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|