blackstack_commons 1.1.35 → 1.1.41
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/extend_string.rb +9 -0
- data/lib/functions.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5c3c238d33d3d4c366b1364178a6528467d81d1
|
4
|
+
data.tar.gz: c4394a462575874d317f2b836a2f2f6863c281b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9968fb30305ca9a039281dd8fa7cf4a63fb8819036f8fb55688151850141e6ebce24acd327c947b371b1d08bf8deffba3230680b2ddf836b8d968c8132bd68ed
|
7
|
+
data.tar.gz: 4ab64b6387a58d8f406e762fa4b8e51837c499e56e6cc716fbbeecaa25e07f6c0be8c96e1569fdfbf505f9ba7288ba1eb5ae88cacc55f1c4eebba34e91f42c69
|
data/lib/extend_string.rb
CHANGED
@@ -108,4 +108,13 @@ class String
|
|
108
108
|
BlackStack::Strings::Encoding::encode_html(self.to_s)
|
109
109
|
end
|
110
110
|
|
111
|
+
# Escapes carriage returns and single and double quotes for JavaScript segments.
|
112
|
+
# reference: https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html
|
113
|
+
def escape_javascript
|
114
|
+
s = self.dup
|
115
|
+
js_escape_map = { '\\' => '\\\\', "</" => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'", "`" => "\\`", "$" => "\\$" }
|
116
|
+
js_escape_map.each { | x, y | s.gsub!(x,y) }
|
117
|
+
s
|
118
|
+
end
|
119
|
+
|
111
120
|
end # class String
|
data/lib/functions.rb
CHANGED
@@ -120,8 +120,8 @@ module BlackStack
|
|
120
120
|
MATCH_PASSWORD = /(?=.*[a-zA-Z])(?=.*[0-9]).{6,}/
|
121
121
|
MATCH_GUID = /{?[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]}?/
|
122
122
|
MATCH_FILENAME = /[\w\-\_\.]+/
|
123
|
-
MATCH_EMAIL = /[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{
|
124
|
-
MATCH_DOMAIN = /(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,
|
123
|
+
MATCH_EMAIL = /[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{1,25}/
|
124
|
+
MATCH_DOMAIN = /(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,10}/
|
125
125
|
MATCH_DATE_STANDARD = /\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])/
|
126
126
|
MATCH_PHONE = /(?:\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}/
|
127
127
|
MATCH_URL = /(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ # /(?:\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}/
|
@@ -246,7 +246,7 @@ module BlackStack
|
|
246
246
|
# units: it is a positive integer
|
247
247
|
def self.encode_period(period, units)
|
248
248
|
s = "Last "
|
249
|
-
s += units.to_s + " " if units.to_i > 1
|
249
|
+
s += units.to_i.to_s + " " if units.to_i > 1
|
250
250
|
s += "Hours" if period.upcase == "H" && units.to_i != 1
|
251
251
|
s += "Days" if period.upcase == "D" && units.to_i != 1
|
252
252
|
s += "Weeks" if period.upcase == "W" && units.to_i != 1
|
@@ -512,7 +512,7 @@ module BlackStack
|
|
512
512
|
end
|
513
513
|
|
514
514
|
# New call_get
|
515
|
-
def self.call_get(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
|
515
|
+
def self.call_get(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, support_redirections=true)
|
516
516
|
uri = URI(url)
|
517
517
|
uri.query = URI.encode_www_form(params)
|
518
518
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
|
@@ -521,7 +521,7 @@ module BlackStack
|
|
521
521
|
res = http.request req
|
522
522
|
case res
|
523
523
|
when Net::HTTPSuccess then res
|
524
|
-
when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params)
|
524
|
+
when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params, false) if support_redirections
|
525
525
|
else
|
526
526
|
res.error!
|
527
527
|
end
|
@@ -534,7 +534,7 @@ module BlackStack
|
|
534
534
|
# ssl_verify_mode: you can disabele SSL verification here.
|
535
535
|
# max_channels: this method use lockfiles to prevent an excesive number of API calls from each datacenter. There is not allowed more simultaneous calls than max_channels.
|
536
536
|
# TODO: setup max_simultaneus_calls in the configurtion file.
|
537
|
-
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE,
|
537
|
+
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, support_redirections=true)
|
538
538
|
=begin
|
539
539
|
# build the lockfile name
|
540
540
|
x = 0
|
@@ -546,8 +546,8 @@ module BlackStack
|
|
546
546
|
end
|
547
547
|
=end
|
548
548
|
begin
|
549
|
-
puts
|
550
|
-
puts "call_post:#{url}:."
|
549
|
+
#puts
|
550
|
+
#puts "call_post:#{url}:."
|
551
551
|
# do the call
|
552
552
|
uri = URI(url)
|
553
553
|
ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
|
@@ -558,7 +558,7 @@ puts "call_post:#{url}:."
|
|
558
558
|
res = http.request req
|
559
559
|
case res
|
560
560
|
when Net::HTTPSuccess then res
|
561
|
-
when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false) if
|
561
|
+
when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false) if support_redirections
|
562
562
|
else
|
563
563
|
res.error!
|
564
564
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|