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: 7963159e6b8f55013940f0de7ec2ce479edeca00
4
- data.tar.gz: a78a4f840277d912dd7208ac9d769223c503f08f
3
+ metadata.gz: 70f3e27b64b52f52548995562513d0a00254625c
4
+ data.tar.gz: 430f37a7a11f7b9192ffa5370c852b4c399ed8c1
5
5
  SHA512:
6
- metadata.gz: b9453d419669d24ca7c8108640cdbfd18bd33ea84b11c4896dd8be046f3fca210dff89df5e29ae1f37ad01b2fc202ddc062eba9476a31f2f5b37f9cf99611a2c
7
- data.tar.gz: fe33e808d60e502a3152e10db4d9df0879b78b0d7239ff68d5184caa2c53fabc26b7d5a2e50dc36e9260536657a40bd2bb12ff92c77c48e576fda105d55366f4
6
+ metadata.gz: 373361dc71facf4e3d51f6554d3a3cebb17174ad0c15d0f53f85acf74879de9ba30522de824ccc1a361ada452293b60e8714e3e8253f2bb107c8e6002e6b721c
7
+ data.tar.gz: eb0e68dcf25828b9372aac543d515fcce23df7106e5b1da346b9c41c84f3439f09de6bd3977ae9cc11d56d42260314f1c480a911171dc26b1171686dcb76a5e0
@@ -1,3 +1,3 @@
1
1
  module AnsiStream
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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 &lt;script&gt;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.innerHTML = text
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.5
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-03-06 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler