better_html 0.0.11 → 0.0.12

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: d7a436fddf6b6fb7942f653d3ac6229e2abaf9b5
4
- data.tar.gz: 0a7be9ddbcb902bc7fc897b7c2ed173fa01aae72
3
+ metadata.gz: b31eee572de6668e1791c716a07c9d93658aa566
4
+ data.tar.gz: 6dd1906d36f68f59fbe4d6386f0d0e7e94ce244b
5
5
  SHA512:
6
- metadata.gz: 882d1cfcc881372d05484aac3177f9c88769b633c0b45f6b56a4cc120c3d41b86d5a13e2eed524725282f625dcadcdf82be97cfb2ba787eada0087ae119c0424
7
- data.tar.gz: c557c7b01ca379062627fc94908b185b94592200d832f62957874567f2dfc41958565a3737290a895bd8e9961cc8c7d6cf9f35a8582a32c436812714da36f925
6
+ metadata.gz: 1c96cfded69fd94221810490e37b279da7e57323062a06416dd3522d8b58971cd2bb727690d0373af647871170698ef4d4b8830f13e8fa3538699224b9c33dc8
7
+ data.tar.gz: 49d55494ae87ce77e2cd45883a8b37b1c999badf3fc8e0a7c06ba4631a4c1d0a698243a4810ec2f6fbd80f88508b3ed4b61e0e54e1d8c08a036c01bea664aa14
@@ -140,6 +140,7 @@ EOF
140
140
  text.content_parts.each do |text_token|
141
141
  case text_token.type
142
142
  when :stmt, :expr_literal, :expr_escaped
143
+ next if text_token.type == :stmt && text_token.code.start_with?('#')
143
144
  begin
144
145
  expr = RubyExpr.parse(text_token.code)
145
146
  validate_ruby_helper(text_token, expr)
@@ -275,7 +276,7 @@ EOF
275
276
 
276
277
  def validate_no_statements(node)
277
278
  node.content_parts.each do |token|
278
- if token.type == :stmt && !(/\A\s*end/m === token.code)
279
+ if token.type == :stmt && !(/\A\s*end/m === token.code) && !token.code.start_with?('#')
279
280
  add_error(
280
281
  "erb statement not allowed here; did you mean '<%=' ?",
281
282
  location: token.location,
@@ -286,6 +287,7 @@ EOF
286
287
 
287
288
  def validate_no_javascript_tag(node)
288
289
  node.content_parts.each do |token|
290
+ next if token.type == :stmt && token.code.start_with?('#')
289
291
  if [:stmt, :expr_literal, :expr_escaped].include?(token.type)
290
292
  expr = begin
291
293
  RubyExpr.parse(token.code)
@@ -1,3 +1,3 @@
1
1
  module BetterHtml
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -11,6 +11,30 @@ module BetterHtml
11
11
  )
12
12
  end
13
13
 
14
+ test "multi line erb comments in text" do
15
+ errors = parse(<<-EOF).errors
16
+ text
17
+ <%#
18
+ this is a nice comment
19
+ !@\#{$%?&*()}
20
+ %>
21
+ EOF
22
+
23
+ assert_predicate errors, :empty?
24
+ end
25
+
26
+ test "multi line erb comments in html attribute" do
27
+ errors = parse(<<-EOF).errors
28
+ <div title="
29
+ <%#
30
+ this is a comment right in the middle of an attribute for some reason
31
+ %>
32
+ ">
33
+ EOF
34
+
35
+ assert_predicate errors, :empty?
36
+ end
37
+
14
38
  test "string without interpolation is safe" do
15
39
  errors = parse(<<-EOF).errors
16
40
  <a onclick="alert('<%= "something" %>')">
@@ -269,6 +293,16 @@ module BetterHtml
269
293
  assert_equal "erb statement not allowed here; did you mean '<%=' ?", errors.first.message
270
294
  end
271
295
 
296
+ test "erb comments allowed in scripts" do
297
+ errors = parse(<<-EOF).errors
298
+ <script type="text/javascript">
299
+ <%# comment %>
300
+ </script>
301
+ EOF
302
+
303
+ assert_predicate errors, :empty?
304
+ end
305
+
272
306
  test "script tag without content" do
273
307
  errors = parse(<<-EOF).errors
274
308
  <script type="text/javascript"></script>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francois Chagnon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-14 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi