react_on_rails 16.4.0.rc.0 → 16.4.0.rc.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/react_on_rails/helper.rb +15 -11
- data/lib/react_on_rails/pro_helper.rb +11 -4
- data/lib/react_on_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9598839cf6698d283c5549d221dd23a2b67903cbc8620fb037012b74bc0d0a61
|
|
4
|
+
data.tar.gz: 7b89e0d293d6aa02af9b404732adf5376a4c9411e180a880a538db48e8fa337c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78464cfa9ffbaae7606fbb68cafb3189dba19a0aa731af101d6eae85ed8ce66fb9d44e5f5bf6444377d011621b599a63a742b25621213b744d711950c9ca123a
|
|
7
|
+
data.tar.gz: 51b18f716f5d6cadcc777c14fee9430f3c40375932be3f9576e355564365995768f635a45ecd29c2605ad9eac146ee85a0a2190acdd700b10cd71aa58046fa59
|
data/Gemfile.lock
CHANGED
|
@@ -480,23 +480,27 @@ module ReactOnRails
|
|
|
480
480
|
)
|
|
481
481
|
end
|
|
482
482
|
|
|
483
|
+
# Returns the CSP script nonce for the current request, or nil if CSP is not enabled.
|
|
484
|
+
# Rails 5.2-6.0 use content_security_policy_nonce with no arguments.
|
|
485
|
+
# Rails 6.1+ accept an optional directive argument.
|
|
486
|
+
def csp_nonce
|
|
487
|
+
return unless respond_to?(:content_security_policy_nonce)
|
|
488
|
+
|
|
489
|
+
begin
|
|
490
|
+
content_security_policy_nonce(:script)
|
|
491
|
+
rescue ArgumentError
|
|
492
|
+
# Fallback for Rails versions that don't accept arguments
|
|
493
|
+
content_security_policy_nonce
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
483
497
|
# Wraps console replay JavaScript code in a script tag with CSP nonce if available.
|
|
484
498
|
# The console_script_code is already sanitized by scriptSanitizedVal() in the JavaScript layer,
|
|
485
499
|
# so using html_safe here is secure.
|
|
486
500
|
def wrap_console_script_with_nonce(console_script_code)
|
|
487
501
|
return "" if console_script_code.blank?
|
|
488
502
|
|
|
489
|
-
|
|
490
|
-
# Rails 5.2-6.0 use content_security_policy_nonce with no arguments
|
|
491
|
-
# Rails 6.1+ accept an optional directive argument
|
|
492
|
-
nonce = if respond_to?(:content_security_policy_nonce)
|
|
493
|
-
begin
|
|
494
|
-
content_security_policy_nonce(:script)
|
|
495
|
-
rescue ArgumentError
|
|
496
|
-
# Fallback for Rails versions that don't accept arguments
|
|
497
|
-
content_security_policy_nonce
|
|
498
|
-
end
|
|
499
|
-
end
|
|
503
|
+
nonce = csp_nonce
|
|
500
504
|
|
|
501
505
|
# Build the script tag with nonce if available
|
|
502
506
|
script_options = { id: "consoleReplayLog" }
|
|
@@ -24,9 +24,11 @@ module ReactOnRails
|
|
|
24
24
|
spec_tag = if render_options.immediate_hydration
|
|
25
25
|
# Escape dom_id for JavaScript context
|
|
26
26
|
escaped_dom_id = escape_javascript(render_options.dom_id)
|
|
27
|
+
nonce = csp_nonce
|
|
28
|
+
script_options = nonce.present? ? { nonce: nonce } : {}
|
|
27
29
|
immediate_script = content_tag(:script, %(
|
|
28
30
|
typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsComponentLoaded('#{escaped_dom_id}');
|
|
29
|
-
).html_safe)
|
|
31
|
+
).html_safe, script_options)
|
|
30
32
|
"#{component_specification_tag}\n#{immediate_script}"
|
|
31
33
|
else
|
|
32
34
|
component_specification_tag
|
|
@@ -49,9 +51,14 @@ module ReactOnRails
|
|
|
49
51
|
store_hydration_scripts = if redux_store_data[:immediate_hydration]
|
|
50
52
|
# Escape store_name for JavaScript context
|
|
51
53
|
escaped_store_name = escape_javascript(redux_store_data[:store_name])
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
nonce = csp_nonce
|
|
55
|
+
script_options = nonce.present? ? { nonce: nonce } : {}
|
|
56
|
+
immediate_script = content_tag(
|
|
57
|
+
:script,
|
|
58
|
+
<<~JS.strip_heredoc.html_safe,
|
|
59
|
+
typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsStoreLoaded('#{escaped_store_name}');
|
|
60
|
+
JS
|
|
61
|
+
script_options
|
|
55
62
|
)
|
|
56
63
|
"#{store_hydration_data}\n#{immediate_script}"
|
|
57
64
|
else
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: react_on_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.4.0.rc.
|
|
4
|
+
version: 16.4.0.rc.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Gordon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|