upfluence-utils 0.9.2 → 0.10.0
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/upfluence/http/endpoint/api_endpoint.rb +11 -0
- data/lib/upfluence/mixin/html_scrubbing.rb +25 -0
- data/lib/upfluence/resources/countries.rb +9 -17
- data/lib/upfluence/utils/version.rb +1 -1
- data/rbutils.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c8c88069b0d18a4f8f01315a252a691a7410d3dfcfdf268f3c99508b8a31e504
|
|
4
|
+
data.tar.gz: 536742411a6e92e68787c5fdb64f5542f9fcdb6f0e138d9bfa6e3d3d5857e697
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3defd0c55f04af0751f337e50ed62a32915b83d2f9b90ac9aed21513ca38ae37b89d8db49d3614f634596fdad2876316643967c21d5d54bcaf3e543a3068b09
|
|
7
|
+
data.tar.gz: b5ca86d6ca49687d46f5ea3b4b1e2de8b5907f4928335f10212d74ac6772b28d5a16f3891f7f7365828f6c5a49cdc8b72e7260d828e893284cb6641e81c25377
|
|
@@ -2,6 +2,7 @@ require 'sinatra'
|
|
|
2
2
|
require 'active_record'
|
|
3
3
|
require 'active_support/hash_with_indifferent_access'
|
|
4
4
|
require 'upfluence/http/endpoint/validation_error'
|
|
5
|
+
require 'upfluence/mixin/strong_parameters'
|
|
5
6
|
|
|
6
7
|
module Upfluence
|
|
7
8
|
module HTTP
|
|
@@ -99,6 +100,16 @@ module Upfluence
|
|
|
99
100
|
Sinatra::Base.error ActiveRecord::RecordInvalid do |e|
|
|
100
101
|
[422, Base::Exceptions::ValidationError.from_model(e.record).to_json]
|
|
101
102
|
end
|
|
103
|
+
|
|
104
|
+
Sinatra::Base.error Upfluence::Mixin::StrongParameters::ParameterMissing do |e|
|
|
105
|
+
[
|
|
106
|
+
400,
|
|
107
|
+
{
|
|
108
|
+
error: 'missing_parameter',
|
|
109
|
+
param: e.param
|
|
110
|
+
}.to_json
|
|
111
|
+
]
|
|
112
|
+
end
|
|
102
113
|
end
|
|
103
114
|
end
|
|
104
115
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'loofah'
|
|
2
|
+
|
|
3
|
+
module Upfluence
|
|
4
|
+
module Mixin
|
|
5
|
+
module HTMLScrubbing
|
|
6
|
+
def scrub_params(params, *keys)
|
|
7
|
+
keys.reduce(params) do |vs, key|
|
|
8
|
+
if vs.key? key
|
|
9
|
+
vs.merge(key => scrub_value(vs[key]))
|
|
10
|
+
else
|
|
11
|
+
vs
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def scrub_value(value)
|
|
19
|
+
return nil unless value.is_a? String
|
|
20
|
+
|
|
21
|
+
Loofah.fragment(value).scrub!(:prune).to_s
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
module Upfluence
|
|
2
2
|
module Resources
|
|
3
3
|
COUNTRIES = %w[
|
|
4
|
-
US FR GB DE CH AF AL DZ AS AD AO AI
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
MX FM MD MC MN ME MS MA MZ MM NA NR
|
|
14
|
-
NP NL NC NZ NI NE NG NO OM PK PW PS
|
|
15
|
-
PA PG PY PE PH PL PT PR QA RE RO RU
|
|
16
|
-
RW KN LC VC WS SM ST SA SN RS SC SL
|
|
17
|
-
SG SK SI SB SO ZA ES LK SD SR SZ SE
|
|
18
|
-
SY TW TJ TZ TH TL TG TO TT TN TR TM
|
|
19
|
-
TC TV UG UA AE GB UY UZ VU VE VN VG
|
|
20
|
-
VI EH YE ZM ZW CR
|
|
4
|
+
US FR GB DE CH AF AL DZ AS AD AO AI AG AR AM AW AU AT AZ BS BH BD BB BY BE
|
|
5
|
+
BZ BJ BM BT BO BA BW BR BN BG BF BI CV KH CM CA KY CF TD CL CN CO KM CG CD
|
|
6
|
+
CK CI HR CU CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FO FJ FI PF GA GM GE GH
|
|
7
|
+
GI GR GL GD GP GU GT GG GN GW GY HT VA HN HK HU IS IN ID IR IQ IE IM IL IT
|
|
8
|
+
JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LI LS LR LY LT LU MO MK MG MW MY
|
|
9
|
+
MV ML MT MH MQ MR MU MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE
|
|
10
|
+
NG NO OM PK PW PS PA PG PY PE PH PL PT PR QA RE RO RU RW KN LC VC WS SM ST
|
|
11
|
+
SA SN RS SC SL SG SK SI SB SO ZA ES LK SD SR SZ SE SY TW TJ TZ TH TL TG TO
|
|
12
|
+
TT TN TR TM TC TV UG UA AE GB UY UZ VU VE VN VG VI EH YE ZM ZW CR
|
|
21
13
|
].freeze
|
|
22
14
|
end
|
|
23
15
|
end
|
data/rbutils.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: upfluence-utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Upfluence
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -220,6 +220,20 @@ dependencies:
|
|
|
220
220
|
- - ">="
|
|
221
221
|
- !ruby/object:Gem::Version
|
|
222
222
|
version: '0'
|
|
223
|
+
- !ruby/object:Gem::Dependency
|
|
224
|
+
name: loofah
|
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
|
226
|
+
requirements:
|
|
227
|
+
- - ">="
|
|
228
|
+
- !ruby/object:Gem::Version
|
|
229
|
+
version: '0'
|
|
230
|
+
type: :runtime
|
|
231
|
+
prerelease: false
|
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
233
|
+
requirements:
|
|
234
|
+
- - ">="
|
|
235
|
+
- !ruby/object:Gem::Version
|
|
236
|
+
version: '0'
|
|
223
237
|
description:
|
|
224
238
|
email:
|
|
225
239
|
- dev@upfluence.com
|
|
@@ -255,6 +269,7 @@ files:
|
|
|
255
269
|
- lib/upfluence/http/middleware/prometheus.rb
|
|
256
270
|
- lib/upfluence/http/server.rb
|
|
257
271
|
- lib/upfluence/logger.rb
|
|
272
|
+
- lib/upfluence/mixin/html_scrubbing.rb
|
|
258
273
|
- lib/upfluence/mixin/pagination.rb
|
|
259
274
|
- lib/upfluence/mixin/strong_parameters.rb
|
|
260
275
|
- lib/upfluence/peer.rb
|