phlex 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of phlex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/SECURITY.md +5 -0
- data/fixtures/dummy/app/views/articles/index.html.erb +3 -0
- data/fixtures/dummy/app/views/heading.rb +9 -0
- data/lib/phlex/component.rb +9 -4
- data/lib/phlex/html.rb +9 -2
- data/lib/phlex/renderable.rb +7 -1
- data/lib/phlex/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e96f6deb872d9da9c40cece7e93c195fc5f2f58dc1d61a2277318a290018d64
|
4
|
+
data.tar.gz: 759f185fc168d0d98647ad71c589ec8d1425b153382c37a070eb28ca8015c69b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96c765e8a02c0e79cef8d1ed44bac721844e0fd8ae3a7e921176be092775bb66a3cfd6e28a75b697eb8f1debd01c2738e55044fc49a834937c7c79c4220beebb
|
7
|
+
data.tar.gz: b5d99002d25e7a426102b6d935fefe0b18145eb780409745a0c63e6523db3668a12ea896e2155e6d8e2b40acb106d4298a8c8d93fa785c3f44472c4667ad67a4
|
data/README.md
CHANGED
@@ -16,9 +16,9 @@ Everyone interacting in Phlex codebases, issue trackers, chat rooms and mailing
|
|
16
16
|
|
17
17
|
### Sponsorship 💖
|
18
18
|
|
19
|
-
Maintaining a library
|
19
|
+
Maintaining a library is a lot of work. If your company benefits from this work or is likely to benefit from it in the future, please consider [sponsorship](https://github.com/sponsors/joeldrapper). Phlex is actively developed and maintained by **[Joel Drapper](https://github.com/sponsors/joeldrapper)**.
|
20
20
|
|
21
|
-
### Security
|
21
|
+
### Security 🚨
|
22
22
|
|
23
23
|
If you’ve found a potential security issue, please email [joel+security@drapper.me](mailto:joel+security@drapper.me).
|
24
24
|
|
data/SECURITY.md
ADDED
data/lib/phlex/component.rb
CHANGED
@@ -47,15 +47,20 @@ module Phlex
|
|
47
47
|
return unless block_given?
|
48
48
|
|
49
49
|
original_length = @_target.length
|
50
|
-
output = yield(self)
|
50
|
+
output = yield(self)
|
51
51
|
unchanged = (original_length == @_target.length)
|
52
52
|
|
53
|
-
text(output) if unchanged
|
53
|
+
text(output) if unchanged
|
54
54
|
nil
|
55
55
|
end
|
56
56
|
|
57
57
|
def text(content)
|
58
|
-
@_target <<
|
58
|
+
@_target << case content
|
59
|
+
when String then CGI.escape_html(content)
|
60
|
+
when Symbol then CGI.escape_html(content.name)
|
61
|
+
else CGI.escape_html(content.to_s)
|
62
|
+
end
|
63
|
+
|
59
64
|
nil
|
60
65
|
end
|
61
66
|
|
@@ -179,7 +184,7 @@ module Phlex
|
|
179
184
|
when Symbol
|
180
185
|
buffer << " " << name << '="' << CGI.escape_html(v.name) << '"'
|
181
186
|
when Hash
|
182
|
-
_build_attributes(v.transform_keys { "#{k}-#{_1}" }, buffer: buffer)
|
187
|
+
_build_attributes(v.transform_keys { "#{k}-#{_1.name.tr('_', '-')}" }, buffer: buffer)
|
183
188
|
else
|
184
189
|
buffer << " " << name << '="' << CGI.escape_html(v.to_s) << '"'
|
185
190
|
end
|
data/lib/phlex/html.rb
CHANGED
@@ -10,7 +10,7 @@ module Phlex
|
|
10
10
|
|
11
11
|
STANDARD_ELEMENTS = %i[a abbr address article aside b bdi bdo blockquote body button caption cite code colgroup data datalist dd del details dfn dialog div dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header html i iframe ins kbd label legend li main map mark menuitem meter nav noscript object ol optgroup option output p path picture pre progress q rp rt ruby s samp script section select slot small span strong style sub summary sup svg table tbody td textarea tfoot th thead time title tr u ul video wbr].freeze
|
12
12
|
|
13
|
-
VOID_ELEMENTS = %i[area embed img input link meta param track col].freeze
|
13
|
+
VOID_ELEMENTS = %i[area embed img input link meta param source track col].freeze
|
14
14
|
|
15
15
|
EVENT_ATTRIBUTES = %w[onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay oncanplaythrough onchange onclick oncontextmenu oncopy oncuechange oncut ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onerror onfocus onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel onoffline ononline onpagehide onpageshow onpaste onpause onplay onplaying onpopstate onprogress onratechange onreset onresize onscroll onsearch onseeked onseeking onselect onstalled onstorage onsubmit onsuspend ontimeupdate ontoggle onunload onvolumechange onwaiting onwheel].to_h { [_1, true] }.freeze
|
16
16
|
|
@@ -31,7 +31,14 @@ module Phlex
|
|
31
31
|
end
|
32
32
|
else
|
33
33
|
if content
|
34
|
-
|
34
|
+
case content
|
35
|
+
when String
|
36
|
+
@_target << "<#{tag}>" << CGI.escape_html(content) << "</#{tag}>"
|
37
|
+
when Symbol
|
38
|
+
@_target << "<#{tag}>" << CGI.escape_html(content.name) << "</#{tag}>"
|
39
|
+
else
|
40
|
+
@_target << "<#{tag}>" << CGI.escape_html(content.to_s) << "</#{tag}>"
|
41
|
+
end
|
35
42
|
elsif block_given?
|
36
43
|
@_target << "<#{tag}>"
|
37
44
|
content(&block)
|
data/lib/phlex/renderable.rb
CHANGED
@@ -21,7 +21,13 @@ module Phlex
|
|
21
21
|
def render_in(view_context, &block)
|
22
22
|
if block_given?
|
23
23
|
call(view_context: view_context) do |*args, **kwargs|
|
24
|
-
view_context.with_output_buffer(self)
|
24
|
+
view_context.with_output_buffer(self) do
|
25
|
+
original_length = @_target.length
|
26
|
+
output = yield(*args, **kwargs)
|
27
|
+
unchanged = (original_length == @_target.length)
|
28
|
+
|
29
|
+
text(output) if unchanged && output.is_a?(String)
|
30
|
+
end
|
25
31
|
end.html_safe
|
26
32
|
else
|
27
33
|
call(view_context: view_context).html_safe
|
data/lib/phlex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Drapper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- LICENSE.txt
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
|
+
- SECURITY.md
|
42
43
|
- bench.rb
|
43
44
|
- config.ru
|
44
45
|
- docs/assets/application.css
|
@@ -65,6 +66,7 @@ files:
|
|
65
66
|
- fixtures/dummy/app/views/articles/index.html.erb
|
66
67
|
- fixtures/dummy/app/views/articles/new.html.erb
|
67
68
|
- fixtures/dummy/app/views/card.rb
|
69
|
+
- fixtures/dummy/app/views/heading.rb
|
68
70
|
- fixtures/dummy/config/database.yml
|
69
71
|
- fixtures/dummy/config/routes.rb
|
70
72
|
- fixtures/dummy/config/storage.yml
|