makeup 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- makeup (0.4.0)
4
+ makeup (0.4.1)
5
5
  github-linguist (~> 2.8)
6
6
  github-markup (~> 0.7)
7
7
  htmlentities (~> 4.3)
@@ -22,7 +22,7 @@ GEM
22
22
  pygments.rb (~> 0.4.2)
23
23
  github-markup (0.7.5)
24
24
  htmlentities (4.3.1)
25
- mime-types (1.23)
25
+ mime-types (1.24)
26
26
  minitest (2.12.1)
27
27
  multi_json (1.7.7)
28
28
  posix-spawn (0.3.6)
@@ -37,12 +37,11 @@ module Makeup
37
37
  def highlight(path, code, options = {})
38
38
  options[:lexer] ||= lexer(path, code)
39
39
  lexer = Pygments::Lexer.find(options[:lexer])
40
- code = lexer.nil? ? code : Pygments.highlight(code, highlight_options(options))
41
- CodeBlock.new(lexer && lexer.aliases.first, code)
42
- rescue MentosError => e
43
- # "MentosError" is what Pyments.rb raises when an unknown lexer is
44
- # attempted used
45
- CodeBlock.new(nil, @entities.encode(code))
40
+ return unknown_lexer(code) unless lexer
41
+ code = Pygments.highlight(code, highlight_options(options))
42
+ CodeBlock.new(lexer.aliases.first, code)
43
+ rescue MentosError
44
+ unknown_lexer(code)
46
45
  end
47
46
 
48
47
  def lexer(path, code = nil, mode = nil)
@@ -55,6 +54,11 @@ module Makeup
55
54
  end
56
55
 
57
56
  private
57
+
58
+ def unknown_lexer(code)
59
+ CodeBlock.new(nil, @entities.encode(code))
60
+ end
61
+
58
62
  def highlight_options(options = {})
59
63
  options[:options] ||= {}
60
64
  options[:options][:nowrap] = true
@@ -24,5 +24,5 @@
24
24
  #++
25
25
 
26
26
  module Makeup
27
- VERSION = "0.4.0"
27
+ VERSION = "0.4.1"
28
28
  end
@@ -67,6 +67,12 @@ describe Makeup::SyntaxHighlighter do
67
67
 
68
68
  assert_equal "Yeah yeah yeah", html
69
69
  end
70
+
71
+ it "encodes the html entities even with no highliting" do
72
+ html = highlight("file.trololol", "<script>alert('xss')</script>")
73
+
74
+ assert_equal "&lt;script&gt;alert(&apos;xss&apos;)&lt;/script&gt;", html
75
+ end
70
76
  end
71
77
 
72
78
  describe "#lexer" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: makeup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
12
+ date: 2013-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pygments.rb
@@ -164,12 +164,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  - - ! '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ segments:
168
+ - 0
169
+ hash: -4298020726532566832
167
170
  required_rubygems_version: !ruby/object:Gem::Requirement
168
171
  none: false
169
172
  requirements:
170
173
  - - ! '>='
171
174
  - !ruby/object:Gem::Version
172
175
  version: '0'
176
+ segments:
177
+ - 0
178
+ hash: -4298020726532566832
173
179
  requirements: []
174
180
  rubyforge_project: makeup
175
181
  rubygems_version: 1.8.25
@@ -177,4 +183,3 @@ signing_key:
177
183
  specification_version: 3
178
184
  summary: Pretty markup
179
185
  test_files: []
180
- has_rdoc: