blackstack_commons 1.1.34 → 1.1.40

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bf323bf87e9ad791105370e7fbd0a41c7fc50ae
4
- data.tar.gz: 1c7bf646475bb5ab9c1b05080b68c0ded854bced
3
+ metadata.gz: 56845620e1eb854129f21d7bcc71bd7246cc3ef5
4
+ data.tar.gz: 67d73bb64e3c2e2b2157249fd23a2000cfcd39ce
5
5
  SHA512:
6
- metadata.gz: 7914ab263ca9f5ba3d853212bebeea28298aad8e0626cfca93f1904c3bc52c4ca342277bec7f619af3e8737b8b08e4cf7483cb006e2fcb3ae6b39584505b1b46
7
- data.tar.gz: 162f8cb3bfc71412a2ca5e29e9c31c53a09fefa073172c716d014fe4376d35284b67b2ce7b0369119ea93ae875871b2605d316284e013b9324a0a673bb499102
6
+ metadata.gz: f1637f9e742b5bbe7c6df3ef1d83d3917b33896f016bd56b171a46f4611f8fa28308be8d15b3a714b37e15854463c506af71828aaec3a96f13b278d7ae7c2935
7
+ data.tar.gz: ccc0a9d82965d4464d22ea19d3129c18439699f9acd8fb537da3b44c1ed53101da58c55c841242cf96042c31862404334c8925bc1e9d7d05849ba4ab79d3ba2c
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,7 +120,7 @@ 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]{2,4}/
123
+ MATCH_EMAIL = /[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{1,25}/
124
124
  MATCH_DOMAIN = /(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}/
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}/
@@ -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, use_lockfile=true)
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,7 +546,8 @@ module BlackStack
546
546
  end
547
547
  =end
548
548
  begin
549
-
549
+ #puts
550
+ #puts "call_post:#{url}:."
550
551
  # do the call
551
552
  uri = URI(url)
552
553
  ret = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
@@ -557,7 +558,7 @@ module BlackStack
557
558
  res = http.request req
558
559
  case res
559
560
  when Net::HTTPSuccess then res
560
- when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false)
561
+ when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false) if support_redirections
561
562
  else
562
563
  res.error!
563
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.34
4
+ version: 1.1.40
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: 2020-07-22 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning