unpoly-rails 3.3.0 → 3.3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unpoly/rails/change/field.rb +5 -15
- data/lib/unpoly/rails/util.rb +14 -2
- data/lib/unpoly/rails/version.rb +2 -3
- 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: d6168b30ebc03dcb29e92bf01cf3641f450b73c77caf36524583fa285c36e7aa
|
4
|
+
data.tar.gz: dbe8e882e7875489d750a5477ff731941360ae7f8c9e418c728a6893948dc23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29567f4fdb9668df6cba8e4fab7a758dd640395490b39d67ee4187f8474e0ecc4f6c0b36ccda8cf5f54479a642dcb7d30be71b4baeef02d5bf87145fc4ee44f2
|
7
|
+
data.tar.gz: b3f432523d96491a4d0c9908457134999ecfc400c0d26de04ee5ef6105b93a1fb453c44ad4f271f3f22ceb0c654053b46f8107dad0f0d06e10b461ee81b841e7
|
@@ -48,7 +48,7 @@ module Unpoly
|
|
48
48
|
end
|
49
49
|
|
50
50
|
##
|
51
|
-
# An array of strings,
|
51
|
+
# An array of strings, separated by a space character.
|
52
52
|
class SeparatedValues < Field
|
53
53
|
|
54
54
|
def initialize(name, separator: ' ', default: nil)
|
@@ -60,8 +60,8 @@ module Unpoly
|
|
60
60
|
def parse(raw)
|
61
61
|
if raw
|
62
62
|
raw.split(@separator)
|
63
|
-
|
64
|
-
|
63
|
+
else
|
64
|
+
@default&.call
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -101,11 +101,7 @@ module Unpoly
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def parse(raw)
|
104
|
-
|
105
|
-
result = Util.json_decode(raw)
|
106
|
-
elsif @default
|
107
|
-
result = instance_exec(&@default)
|
108
|
-
end
|
104
|
+
result = Util.guard_json_decode(raw, &@default)
|
109
105
|
|
110
106
|
if result.is_a?(::Hash)
|
111
107
|
result = ActiveSupport::HashWithIndifferentAccess.new(result)
|
@@ -132,13 +128,7 @@ module Unpoly
|
|
132
128
|
end
|
133
129
|
|
134
130
|
def parse(raw)
|
135
|
-
|
136
|
-
result = Util.json_decode(raw)
|
137
|
-
elsif @default
|
138
|
-
result = instance_exec(&@default)
|
139
|
-
end
|
140
|
-
|
141
|
-
result
|
131
|
+
Util.guard_json_decode(raw, &@default)
|
142
132
|
end
|
143
133
|
|
144
134
|
def stringify(value)
|
data/lib/unpoly/rails/util.rb
CHANGED
@@ -3,8 +3,20 @@ module Unpoly
|
|
3
3
|
class Util
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def guard_json_decode(raw, &default)
|
7
|
+
if raw.present?
|
8
|
+
begin
|
9
|
+
ActiveSupport::JSON.decode(raw)
|
10
|
+
rescue ActiveSupport::JSON.parse_error
|
11
|
+
# We would love to crash here, as it might indicate a bug in the frontend code.
|
12
|
+
# Unfortunately security scanners may be spamming malformed JSON in X-Up headers,
|
13
|
+
# DOSing us with error notifications.
|
14
|
+
::Rails.logger.error('unpoly-rails: Ignoring malformed JSON in X-Up header')
|
15
|
+
default&.call
|
16
|
+
end
|
17
|
+
else
|
18
|
+
default&.call
|
19
|
+
end
|
8
20
|
end
|
9
21
|
|
10
22
|
# We build a lot of JSON that goes into HTTP header.
|
data/lib/unpoly/rails/version.rb
CHANGED
@@ -2,8 +2,7 @@ module Unpoly
|
|
2
2
|
module Rails
|
3
3
|
##
|
4
4
|
# The current version of the unpoly-rails gem.
|
5
|
-
#
|
6
|
-
|
7
|
-
VERSION = '3.3.0'
|
5
|
+
# The first 3 digits should match the version of the Unpoly frontend code.
|
6
|
+
VERSION = '3.3.0.1'
|
8
7
|
end
|
9
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unpoly-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.0
|
4
|
+
version: 3.3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|