repost 0.4.2 → 0.5.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/lib/repost/extend_controller.rb +13 -8
- data/lib/repost/senpai.rb +18 -19
- data/lib/repost/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77a301cd78a8e6ce5a6b34b8acb0538701b59ca4bc351e40a8095500b0e0a735
|
|
4
|
+
data.tar.gz: 9ee29217ffc133b3ccabe49090844757334e66904135c2aad686a7f17d1dddbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68eab1a118f6407a1432fbad24e8fd553a0460c3821cbb945e829fd3b7afa14da183e323d7d2b64695ae1b454600840fe862b16bb05f7702d5d213ad24b2ad9d
|
|
7
|
+
data.tar.gz: 3e551dc5fa1045f106b7555894f13bb2cd02bc32a5ae6409df8e8096be848e8aea86b5db45d0ea9e7327ee8edf0f040b2958695c5280721d733f89d5828cc4e0
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
if defined?(Rails) && defined?(ActiveSupport)
|
|
2
2
|
ActiveSupport.on_load(:action_controller) do
|
|
3
3
|
class ::ActionController::Base
|
|
4
|
-
|
|
5
4
|
def repost(url, params: {}, options: {})
|
|
6
5
|
status = options.delete(:status) || :ok
|
|
7
|
-
authenticity_token =
|
|
8
|
-
|
|
6
|
+
authenticity_token = if ['auto', :auto].include?(options[:authenticity_token])
|
|
7
|
+
form_authenticity_token
|
|
8
|
+
else
|
|
9
|
+
options[:authenticity_token]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
html_payload = Repost::Senpai.perform(
|
|
9
13
|
url,
|
|
10
14
|
params: params,
|
|
11
15
|
options: options.merge({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
+
authenticity_token: authenticity_token,
|
|
17
|
+
autosubmit_nonce: content_security_policy_nonce
|
|
18
|
+
}.compact)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
render html: html_payload.html_safe, status: status
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
alias :redirect_post :repost
|
|
19
|
-
|
|
20
25
|
end
|
|
21
26
|
end
|
|
22
27
|
end
|
data/lib/repost/senpai.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'cgi'
|
|
2
|
+
|
|
1
3
|
module Repost
|
|
2
4
|
class Senpai < Action
|
|
3
5
|
DEFAULT_SUBMIT_BUTTON_TEXT = 'Continue'
|
|
@@ -21,10 +23,10 @@ module Repost
|
|
|
21
23
|
|
|
22
24
|
def perform
|
|
23
25
|
compiled_body = if autosubmit
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
form_body << auto_submit_script << no_script
|
|
27
|
+
else
|
|
28
|
+
form_body << submit_section
|
|
29
|
+
end
|
|
28
30
|
form_head << compiled_body << form_footer
|
|
29
31
|
end
|
|
30
32
|
|
|
@@ -34,8 +36,12 @@ module Repost
|
|
|
34
36
|
:section_classes, :section_html, :submit_classes,
|
|
35
37
|
:submit_text, :authenticity_token, :charset, :autosubmit_nonce
|
|
36
38
|
|
|
39
|
+
def escape(value)
|
|
40
|
+
CGI.escapeHTML(value.to_s)
|
|
41
|
+
end
|
|
42
|
+
|
|
37
43
|
def form_head
|
|
38
|
-
%Q(<form id="#{form_id}" action="#{url}" method="#{method}" accept-charset="#{charset}">)
|
|
44
|
+
%Q(<form id="#{escape(form_id)}" action="#{escape(url)}" method="#{escape(method)}" accept-charset="#{escape(charset)}">)
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
def form_body
|
|
@@ -57,7 +63,7 @@ module Repost
|
|
|
57
63
|
form_input("#{key}[]", inner_value)
|
|
58
64
|
end.join
|
|
59
65
|
else
|
|
60
|
-
%Q(<input type="hidden" name="#{key}" value
|
|
66
|
+
%Q(<input type="hidden" name="#{escape(key)}" value="#{escape(value)}">)
|
|
61
67
|
end
|
|
62
68
|
end
|
|
63
69
|
|
|
@@ -66,19 +72,17 @@ module Repost
|
|
|
66
72
|
end
|
|
67
73
|
|
|
68
74
|
def csrf_token
|
|
69
|
-
%Q(<input name="authenticity_token" value="#{authenticity_token}" type="hidden">)
|
|
75
|
+
%Q(<input name="authenticity_token" value="#{escape(authenticity_token)}" type="hidden">)
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
def no_script
|
|
73
|
-
%Q(<noscript>
|
|
74
|
-
#{submit_section}
|
|
75
|
-
</noscript>)
|
|
79
|
+
%Q(<noscript>#{submit_section}</noscript>)
|
|
76
80
|
end
|
|
77
81
|
|
|
78
82
|
def submit_section
|
|
79
|
-
%Q(<div class="#{section_classes}">
|
|
83
|
+
%Q(<div class="#{escape(section_classes)}">
|
|
80
84
|
#{section_html}
|
|
81
|
-
<input class="#{submit_classes}" type="submit" value="#{submit_text}"
|
|
85
|
+
<input class="#{escape(submit_classes)}" type="submit" value="#{escape(submit_text)}">
|
|
82
86
|
</div>)
|
|
83
87
|
end
|
|
84
88
|
|
|
@@ -87,15 +91,10 @@ module Repost
|
|
|
87
91
|
end
|
|
88
92
|
|
|
89
93
|
def auto_submit_script
|
|
90
|
-
nonce_attr = %Q( nonce="#{autosubmit_nonce}") if autosubmit_nonce
|
|
94
|
+
nonce_attr = %Q( nonce="#{escape(autosubmit_nonce)}") if autosubmit_nonce
|
|
91
95
|
%Q(<script#{nonce_attr}>
|
|
92
|
-
document.getElementById("#{form_id}").submit();
|
|
96
|
+
document.getElementById("#{escape(form_id)}").submit();
|
|
93
97
|
</script>)
|
|
94
98
|
end
|
|
95
|
-
|
|
96
|
-
def process_value(value)
|
|
97
|
-
return value if value.is_a?(Integer)
|
|
98
|
-
%Q("#{value.to_s.gsub("\"", '\'')}")
|
|
99
|
-
end
|
|
100
99
|
end
|
|
101
100
|
end
|
data/lib/repost/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: repost
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- YaroslavO
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version: 3.
|
|
75
|
+
rubygems_version: 3.4.6
|
|
76
76
|
signing_key:
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: Gem implements Redirect using POST method
|