onebox 2.2.1 → 2.2.8

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
  SHA256:
3
- metadata.gz: 90c9d1f633caf0798657ff3655a0d41cca71364ed0199bc3beea5f686df4c148
4
- data.tar.gz: 8360d4b10bf5af91a8905e09777bd305545a8db0448b9b80301b39b7bd37b1ca
3
+ metadata.gz: 5899faff4b0c2e96d766892a810e866e28a188dbd7b9e8b2c7bdd6bc5a7d7490
4
+ data.tar.gz: 7d739d48349f32dc3f0675d85b29446d6f758f276b845543cc9f9d359c9eb664
5
5
  SHA512:
6
- metadata.gz: 232104ac79cb41e53b404e90e930d1ed229f07df11dab37d72d5267366082f8d26a9d7185dd1b51a3dfe2d1eac9d71f30fddde58203fadffb8c209bcfdfa5cd2
7
- data.tar.gz: f25d39bc21a67607a78924abee0d31ce18137d06fc672fe820cd9d0758a155e3e5370795c924bc1f404b2be41cfd93669c7709d9616043828ee1cca588afe2b4
6
+ metadata.gz: 790964df42c83ea05ff052727a7ad4b567f6064be1a25bf974eeac661a6f7daa3696c64686f21bb83df30ad280caffc36b2039e3c0b799a3171713d61c88eff2
7
+ data.tar.gz: de30b5e5e6110fd72c0aa792aebffa7571c50f04604efedac648e754a527f4945a784328eb43ce0352e9b06eeac908ea23ff0dcdf3ce4d84ecb5e8c3dd64dfd6
@@ -15,24 +15,19 @@ jobs:
15
15
  strategy:
16
16
  matrix:
17
17
  ruby:
18
- - 2.4
19
18
  - 2.5
20
19
  - 2.6
20
+ - 2.7
21
+ - 3.0
21
22
 
22
23
  steps:
23
- - uses: actions/checkout@v1
24
+ - uses: actions/checkout@v2
24
25
 
25
26
  - name: Setup ruby
26
- uses: actions/setup-ruby@v1
27
+ uses: ruby/setup-ruby@v1
27
28
  with:
28
29
  ruby-version: ${{ matrix.ruby }}
29
- architecture: 'x64'
30
-
31
- - name: Setup bundler
32
- run: gem install bundler
33
-
34
- - name: Setup gems
35
- run: bundle install
30
+ bundler-cache: true
36
31
 
37
32
  - name: Rubocop
38
33
  run: bundle exec rubocop
@@ -49,6 +44,6 @@ jobs:
49
44
  - uses: actions/checkout@v2
50
45
 
51
46
  - name: Release Gem
52
- uses: CvX/publish-rubygems-action@master
47
+ uses: discourse/publish-rubygems-action@main
53
48
  env:
54
49
  RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
@@ -227,8 +227,10 @@ module Onebox
227
227
  d[:image] = d[:image_secure_url] || d[:image_url] || d[:thumbnail_url] || d[:image]
228
228
  d[:image] = Onebox::Helpers::get_absolute_image_url(d[:image], @url)
229
229
  d[:image] = Onebox::Helpers::normalize_url_for_output(html_entities.decode(d[:image]))
230
+ d[:image] = nil if Onebox::Helpers.blank?(d[:image])
230
231
 
231
232
  d[:video] = d[:video_secure_url] || d[:video_url] || d[:video]
233
+ d[:video] = nil if Onebox::Helpers.blank?(d[:video])
232
234
 
233
235
  d[:published_time] = d[:article_published_time] unless Onebox::Helpers.blank?(d[:article_published_time])
234
236
  if !Onebox::Helpers.blank?(d[:published_time])
@@ -28,7 +28,7 @@ module Onebox
28
28
  def http_params
29
29
  {
30
30
  'User-Agent' =>
31
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3'
31
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
32
32
  }
33
33
  end
34
34
 
@@ -15,7 +15,7 @@ module Onebox
15
15
  escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
16
16
 
17
17
  <<-HTML
18
- <audio controls>
18
+ <audio controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>
19
19
  <source src="#{escaped_url}">
20
20
  <a href="#{escaped_url}">#{@url}</a>
21
21
  </audio>
@@ -22,8 +22,7 @@ module Onebox
22
22
  end
23
23
 
24
24
  def data
25
-
26
- @raw ||= ::MultiJson.load(open(url, "Accept" => "application/vnd.github.v3.text+json", read_timeout: timeout)) #custom Accept header so we can get body as text.
25
+ @raw ||= ::MultiJson.load(URI.open(url, "Accept" => "application/vnd.github.v3.text+json", read_timeout: timeout)) #custom Accept header so we can get body as text.
27
26
  body_text = @raw["body_text"]
28
27
 
29
28
  content_words = body_text.gsub("\n\n", "\n").gsub("\n", "<br>").split(" ") #one pass of removing double newline, then we change \n to <br> and later on we revert it back to \n this is a workaround to avoid losing newlines after we join it back.
@@ -6,7 +6,7 @@ module Onebox
6
6
  private
7
7
 
8
8
  def raw
9
- @raw ||= ::MultiJson.load(open(url, read_timeout: timeout))
9
+ @raw ||= ::MultiJson.load(URI.open(url, read_timeout: timeout))
10
10
  end
11
11
  end
12
12
  end
@@ -11,7 +11,7 @@ module Onebox
11
11
  private
12
12
 
13
13
  def get_xml
14
- doc = Nokogiri::XML(open(URI.join(@url, "?report=xml&format=text")))
14
+ doc = Nokogiri::XML(URI.open(URI.join(@url, "?report=xml&format=text")))
15
15
  pre = doc.xpath("//pre")
16
16
  Nokogiri::XML("<root>" + pre.text + "</root>")
17
17
  end
@@ -8,6 +8,7 @@ module Onebox
8
8
 
9
9
  matches_regexp(/https?:\/\/(.+)?simplecast.com\/(episodes|s)\/.*/)
10
10
  always_https
11
+ requires_iframe_origins("https://embed.simplecast.com")
11
12
 
12
13
  def to_html
13
14
  get_oembed.html
@@ -20,7 +20,7 @@ module Onebox
20
20
  escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
21
21
  <<-HTML
22
22
  <div class="onebox video-onebox">
23
- <video width='100%' height='100%' controls>
23
+ <video width='100%' height='100%' controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>
24
24
  <source src='#{escaped_url}'>
25
25
  <a href='#{escaped_url}'>#{@url}</a>
26
26
  </video>
@@ -178,6 +178,10 @@ module Onebox
178
178
  url.gsub!("'", "&apos;")
179
179
  url.gsub!('"', "&quot;")
180
180
  url.gsub!(/[^\w\-`.~:\/?#\[\]@!$&'\(\)*+,;=%\p{M}’]/, "")
181
+
182
+ parsed = Addressable::URI.parse(url)
183
+ return "" unless parsed.host
184
+
181
185
  url
182
186
  end
183
187
 
@@ -167,7 +167,7 @@ module Onebox
167
167
  @raw = "https://render.githubusercontent.com/view/solid?url=" + self.raw_template(m)
168
168
 
169
169
  else
170
- contents = open(self.raw_template(m), read_timeout: timeout).read
170
+ contents = URI.open(self.raw_template(m), read_timeout: timeout).read
171
171
 
172
172
  contents_lines = contents.lines #get contents lines
173
173
  contents_lines_size = contents_lines.size #get number of lines
@@ -32,7 +32,8 @@ module Onebox
32
32
  if method_name.end_with?(*integer_suffixes)
33
33
  value.to_i
34
34
  elsif method_name.end_with?(*url_suffixes)
35
- ::Onebox::Helpers.normalize_url_for_output(value)
35
+ result = Onebox::Helpers.normalize_url_for_output(value)
36
+ result unless Onebox::Helpers::blank?(result)
36
37
  else
37
38
  value
38
39
  end
@@ -10,7 +10,7 @@ class Sanitize
10
10
 
11
11
  attributes: {
12
12
  'a' => RELAXED[:attributes]['a'] + %w(target),
13
- 'audio' => %w[controls],
13
+ 'audio' => %w[controls controlslist],
14
14
  'embed' => %w[height src type width],
15
15
  'iframe' => %w[allowfullscreen frameborder height scrolling src width data-original-href data-unsanitized-src],
16
16
  'source' => %w[src type],
@@ -35,7 +35,7 @@ module Onebox
35
35
  private
36
36
 
37
37
  def check
38
- res = open(@url, read_timeout: (@options.timeout || Onebox.options.timeout))
38
+ res = URI.open(@url, read_timeout: (@options.timeout || Onebox.options.timeout))
39
39
  @status = res.status.first.to_i
40
40
  rescue OpenURI::HTTPError => e
41
41
  @status = e.io.status.first.to_i
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "2.2.1"
4
+ VERSION = "2.2.8"
5
5
  end
data/onebox.gemspec CHANGED
@@ -41,5 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency 'haml', '~> 5.1'
42
42
  spec.add_development_dependency 'listen', '~> 2.10.0'
43
43
 
44
- spec.required_ruby_version = '>=2.4.0'
44
+ spec.required_ruby_version = '>=2.5.0'
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-12-24 00:00:00.000000000 Z
13
+ date: 2021-03-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -413,7 +413,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
413
413
  requirements:
414
414
  - - ">="
415
415
  - !ruby/object:Gem::Version
416
- version: 2.4.0
416
+ version: 2.5.0
417
417
  required_rubygems_version: !ruby/object:Gem::Requirement
418
418
  requirements:
419
419
  - - ">="