phlex 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b009908cf2bca382857d9e6adaf26040bbc72df73b4227546e48888d508552f0
4
- data.tar.gz: 560928a3386b32c8f0a94a31462d29b9ff73bcbeb9ecad1171399c1f749be871
3
+ metadata.gz: cbcab903b6e369e32bd8a3cf6645bde4b53284e11d8110d3cf18f7370e2eea83
4
+ data.tar.gz: a38a1e0bfd2ff5ad3940b894ee2efd9c72803412c4a909e0cdc7b5d3eed0cbfe
5
5
  SHA512:
6
- metadata.gz: eb282ecd7594914cd485309e270748d64e3b74bed6fd49ec98244ea34e1fb90cbba0ff542909ee59d3347dce6cde47604aeb67efae605ccfa554473ed8934f61
7
- data.tar.gz: 05ff1300599f9360d07d249e27ee3ef84667c77268bbe25c92a0609686e594f45aa377068714690ca55ee925548d85406b84aa3b3bad26d2eb2c6beb2dd12bf4
6
+ metadata.gz: eda6a5b7939f09ffe5926187f24e5c2af792845eeed880f5f6765a4a365e3f3539673bbe502dd557a2e709c791a36412adc12ab960fd1822ff5bbf3c089bc886
7
+ data.tar.gz: db59525d096e1398a4d6880f74c6d9b6d64167c101c9a7959d4ec265eb89b602d05ff7f117daadcf75c56cf7065181ac683c648f6120ba938f38577a68c6bbd6
data/lib/phlex/sgml.rb CHANGED
@@ -4,11 +4,20 @@ module Phlex
4
4
  # **Standard Generalized Markup Language** for behaviour common to {HTML} and {SVG}.
5
5
  class SGML
6
6
  include Helpers
7
- REF_ATTRIBUTES = Set.new(%w[href src action formaction lowsrc dynsrc background ping xlinkhref]).freeze
7
+ # SVG animation elements, such as `set` and `animate`, write `to`, `from`,
8
+ # `by` and `values` to the attribute their `attributeName` names, which can
9
+ # be `href`, so those are checked as references too.
10
+ REF_ATTRIBUTES = Set.new(%w[href src action formaction lowsrc dynsrc background ping xlinkhref to from by values]).freeze
11
+ # References whose value is a `;`-separated list, any entry of which can be used.
12
+ REF_LIST_ATTRIBUTES = Set.new(%w[values]).freeze
13
+ # `data` takes a URL on `object`. A Hash given to it expands into `data-*`
14
+ # attributes instead, and isn't checked.
15
+ DATA_ATTRIBUTE = "data"
8
16
  NAMED_CHARACTER_REFERENCES = {
9
17
  "colon" => ":",
10
18
  "tab" => "\t",
11
19
  "newline" => "\n",
20
+ "semi" => ";",
12
21
  }.freeze
13
22
  UNSAFE_ATTRIBUTE_NAME_CHARS = %r([<>&"'/=\s\x00])
14
23
 
@@ -463,19 +472,45 @@ module Phlex
463
472
  lower_name = name.downcase
464
473
  normalized_name = lower_name.delete("^a-z")
465
474
 
466
- if REF_ATTRIBUTES.include?(normalized_name)
467
- decoded_value = case v
468
- when String then decode_html_character_references(v)
469
- when Symbol then decode_html_character_references(v.name)
475
+ if REF_ATTRIBUTES.include?(normalized_name) || DATA_ATTRIBUTE == normalized_name
476
+ # The text the value will be rendered as, whatever its type, so a
477
+ # URI or a list of tokens is checked like a String.
478
+ reference = case v
479
+ when String then v
480
+ when Symbol then v.name
481
+ when Array then v.compact.join(" ")
482
+ when Set then v.to_a.compact.join(" ")
483
+ when true, Integer, Float, Hash then nil
484
+ else
485
+ if v.respond_to?(:to_phlex_attribute_value)
486
+ v.to_phlex_attribute_value.to_s
487
+ elsif v.respond_to?(:to_str)
488
+ v.to_str
489
+ else
490
+ v.to_s
491
+ end
470
492
  end
471
493
 
472
- if decoded_value && decoded_value.downcase.tr("^a-z:", "").start_with?("javascript:")
473
- next
494
+ decoded_value = reference && decode_html_character_references(reference)
495
+
496
+ if decoded_value
497
+ decoded_value = decoded_value.downcase
498
+
499
+ if REF_LIST_ATTRIBUTES.include?(normalized_name)
500
+ # The decoder removes references it doesn't know, but a browser keeps
501
+ # them as text, so it could see a `;` the decoder removed. Removing
502
+ # text can't break up an entry's `javascript:`, so the list is unsafe
503
+ # if `javascript:` appears anywhere in it.
504
+ next if decoded_value.tr("^a-z:", "").include?("javascript:")
505
+ elsif decoded_value.tr("^a-z:", "").start_with?("javascript:")
506
+ next
507
+ end
474
508
  end
475
509
  end
476
510
 
477
- # Detect unsafe attribute names. Attribute names are considered unsafe if they match an event attribute or include unsafe characters.
478
- if HTML::EVENT_ATTRIBUTES.include?(lower_name.tr("^a-z-", "")) || name.match?(UNSAFE_ATTRIBUTE_NAME_CHARS)
511
+ # Detect unsafe attribute names. Attribute names are considered unsafe if they look like an event attribute, `on` followed by letters, or include unsafe characters.
512
+ event_name = lower_name.tr("^a-z-", "")
513
+ if (event_name.length > 2 && event_name.start_with?("on") && !event_name.include?("-")) || name.match?(UNSAFE_ATTRIBUTE_NAME_CHARS)
479
514
  raise ArgumentError, "Unsafe attribute name detected: #{k}."
480
515
  end
481
516
 
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "1.11.1"
4
+ VERSION = "1.11.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2026-02-06 00:00:00.000000000 Z
11
+ date: 2026-11-23 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: A high-performance view framework optimised for fun.
13
14
  email:
@@ -46,6 +47,7 @@ metadata:
46
47
  changelog_uri: https://github.com/phlex-ruby/phlex/blob/main/CHANGELOG.md
47
48
  funding_uri: https://github.com/sponsors/joeldrapper
48
49
  rubygems_mfa_required: 'true'
50
+ post_install_message:
49
51
  rdoc_options: []
50
52
  require_paths:
51
53
  - lib
@@ -60,7 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
62
  - !ruby/object:Gem::Version
61
63
  version: '0'
62
64
  requirements: []
63
- rubygems_version: 3.6.2
65
+ rubygems_version: 3.5.3
66
+ signing_key:
64
67
  specification_version: 4
65
68
  summary: A fun framework for building views in Ruby.
66
69
  test_files: []