hamlit 2.14.3 → 2.14.4

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
  SHA256:
3
- metadata.gz: 8411628a286cbe1cca22d568a4b2f44e4020ef65900b3e318726e51ba2c0d89e
4
- data.tar.gz: c80c4c4a4bf7d860d3fca4d5d27f94ef1825ff4027842b64153ecb8eb979e528
3
+ metadata.gz: f7ba07071048a08ffc2c58df5987c6772236c1b895b9a301881d27c13311d318
4
+ data.tar.gz: cde3a650bcc4d06ac8909447203f90b99460ff187140347c9e528107bc62a1bc
5
5
  SHA512:
6
- metadata.gz: 97df4a6d73c8745648158562e3ed41e104d87e0bf4a0245dd0948c3cf92ee434b289bc359de007c236b223c55f62d3704bb0c915d6f0912f5081266a21ddf06e
7
- data.tar.gz: cf29b17b64a66bc104b23a1bf115a3719ebd21b1db357c1d987a356c185d5d13b8bf179956f554d63383b0ad196d909230e8282ef69afb68158ea893f1ed0d61
6
+ metadata.gz: de8bf0cddb83e2fd86b7876461e0b44c46eced02dc85b6375e60c3669d31b4079a9e8142842abb9a5b09dbf806c1d7288f96fbc4000168659029b115e033c7a9
7
+ data.tar.gz: 759a9899a5aaa126c10d5894294c66af62d74585f4d2eb99e4ed9813554fa7a07aade664071c529d7ebb71d72c62b87636abd9d09e3e82e77c8fb1193ee7ad8b
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This
4
4
  project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
5
5
  [keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
6
6
 
7
+ ## [2.14.4](https://github.com/k0kubun/hamlit/compare/v2.14.3...v2.14.4) - 2021-02-01
8
+
9
+ ### Fixed
10
+
11
+ - Prevent another SEGV in a C extension after `GC.compact` [#177](https://github.com/k0kubun/hamlit/issues/177)
12
+ *Thanks to @stanhu*
13
+
7
14
  ## [2.14.3](https://github.com/k0kubun/hamlit/compare/v2.14.2...v2.14.3) - 2021-01-24
8
15
 
9
16
  ### Fixed
data/ext/hamlit/hamlit.c CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  VALUE mAttributeBuilder, mObjectRef;
8
8
  static ID id_flatten, id_keys, id_parse, id_prepend, id_tr, id_uniq_bang;
9
- static ID id_boolean_attributes, id_xhtml;
9
+ static ID id_xhtml;
10
10
 
11
11
  static VALUE str_aria, str_data, str_equal, str_hyphen, str_space, str_underscore;
12
12
 
@@ -342,13 +342,10 @@ merge_all_attrs(VALUE hashes)
342
342
  }
343
343
 
344
344
  int
345
- is_boolean_attribute(VALUE key)
345
+ is_boolean_attribute(VALUE key, VALUE boolean_attributes)
346
346
  {
347
- VALUE boolean_attributes;
348
347
  if (str_eq(rb_str_substr(key, 0, 5), "data-", 5)) return 1;
349
348
  if (str_eq(rb_str_substr(key, 0, 5), "aria-", 5)) return 1;
350
-
351
- boolean_attributes = rb_const_get(mAttributeBuilder, id_boolean_attributes);
352
349
  return RTEST(rb_ary_includes(boolean_attributes, key));
353
350
  }
354
351
 
@@ -418,7 +415,7 @@ hamlit_build_for_boolean(VALUE escape_attrs, VALUE quote, VALUE format, VALUE bu
418
415
  }
419
416
 
420
417
  static VALUE
421
- hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VALUE hashes)
418
+ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE boolean_attributes, VALUE object_ref, VALUE hashes)
422
419
  {
423
420
  long i;
424
421
  VALUE attrs, buf, key, keys, value;
@@ -439,7 +436,7 @@ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VA
439
436
  hamlit_build_for_data(escape_attrs, quote, buf, value);
440
437
  } else if (str_eq(key, "aria", 4)) {
441
438
  hamlit_build_for_aria(escape_attrs, quote, buf, value);
442
- } else if (is_boolean_attribute(key)) {
439
+ } else if (is_boolean_attribute(key, boolean_attributes)) {
443
440
  hamlit_build_for_boolean(escape_attrs, quote, format, buf, key, value);
444
441
  } else {
445
442
  hamlit_build_for_others(escape_attrs, quote, buf, key, value);
@@ -498,10 +495,10 @@ rb_hamlit_build(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
498
495
  {
499
496
  VALUE array;
500
497
 
501
- rb_check_arity(argc, 4, UNLIMITED_ARGUMENTS);
502
- rb_scan_args(argc - 4, argv + 4, "*", &array);
498
+ rb_check_arity(argc, 5, UNLIMITED_ARGUMENTS);
499
+ rb_scan_args(argc - 5, argv + 5, "*", &array);
503
500
 
504
- return hamlit_build(argv[0], argv[1], argv[2], argv[3], array);
501
+ return hamlit_build(argv[0], argv[1], argv[2], argv[3], argv[4], array);
505
502
  }
506
503
 
507
504
  void
@@ -527,9 +524,7 @@ Init_hamlit(void)
527
524
  id_prepend = rb_intern("prepend");
528
525
  id_tr = rb_intern("tr");
529
526
  id_uniq_bang = rb_intern("uniq!");
530
-
531
- id_boolean_attributes = rb_intern("BOOLEAN_ATTRIBUTES");
532
- id_xhtml = rb_intern("xhtml");
527
+ id_xhtml = rb_intern("xhtml");
533
528
 
534
529
  // Consider using rb_interned_str() once we stop supporting Ruby 2.7.
535
530
  rb_gc_register_mark_object(str_aria = rb_obj_freeze(rb_str_new_cstr("aria")));
@@ -13,7 +13,7 @@ module Hamlit::AttributeBuilder
13
13
  # TruffleRuby does not implement `rb_ary_sort_bang`, etc.
14
14
  if /java/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
15
15
  class << self
16
- def build(escape_attrs, quote, format, object_ref, *hashes)
16
+ def build(escape_attrs, quote, format, boolean_attributes, object_ref, *hashes)
17
17
  hashes << Hamlit::ObjectRef.parse(object_ref) if object_ref
18
18
  buf = []
19
19
  hash = merge_all_attrs(hashes)
@@ -27,7 +27,7 @@ module Hamlit::AttributeBuilder
27
27
  buf << " class=#{quote}#{build_class(escape_attrs, *hash[key])}#{quote}"
28
28
  when 'data'.freeze
29
29
  buf << build_data(escape_attrs, quote, *hash[key])
30
- when *BOOLEAN_ATTRIBUTES, /\Adata-/
30
+ when *boolean_attributes, /\Adata-/
31
31
  build_boolean!(escape_attrs, quote, format, buf, key, hash[key])
32
32
  else
33
33
  buf << " #{key}=#{quote}#{escape_html(escape_attrs, hash[key].to_s)}#{quote}"
@@ -31,7 +31,10 @@ module Hamlit
31
31
  attrs = []
32
32
  attrs.unshift(node.value[:attributes].inspect) if node.value[:attributes] != {}
33
33
 
34
- args = [@escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect].push(node.value[:object_ref]) + attrs
34
+ args = [
35
+ @escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect,
36
+ '::Hamlit::AttributeBuilder::BOOLEAN_ATTRIBUTES', node.value[:object_ref],
37
+ ] + attrs
35
38
  [:html, :attrs, [:dynamic, "::Hamlit::AttributeBuilder.build(#{args.join(', ')}, #{node.value[:dynamic_attributes].to_literal})"]]
36
39
  end
37
40
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hamlit
3
- VERSION = '2.14.3'
3
+ VERSION = '2.14.4'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.3
4
+ version: 2.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-24 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  - !ruby/object:Gem::Version
392
392
  version: '0'
393
393
  requirements: []
394
- rubygems_version: 3.2.6
394
+ rubygems_version: 3.1.2
395
395
  signing_key:
396
396
  specification_version: 4
397
397
  summary: High Performance Haml Implementation