brand_logo 2.0.0 → 2.0.1

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: 8ca5db19ef68c02172defd8e04ba4a228c5819c32e3f2aa8dd10de412b4889f1
4
- data.tar.gz: 6a1bf3a2bda344977f005a0c12ae07c884fa24bc19d5bdabc650ccb57f2e9806
3
+ metadata.gz: e165515641f5a8bf584699ee81dbdf62040409d00b06ea0052a4270e7c25abc7
4
+ data.tar.gz: 915f8dd74b6df4eb896328298e5b6859d87fe95ca14e287f2b1f30b80d14372a
5
5
  SHA512:
6
- metadata.gz: ee0e662864b0ede5a0a78b538109468efc96db273c41bb37ccb20c36f808e3869258e5e29792c8dfcb5a7410fc3c4fe45ffa8e9f6a3453197e421abc80a08173
7
- data.tar.gz: 74c9c3d4fe4102fdc86bd2070129dc93b9f7b09da79677278c1ea0b3e4bc1cfdc6779195f4b800e0ea9d410c71b0f2d72f89c3ab59354d40b34385bac48557f3
6
+ metadata.gz: f03b21ed953c2320a238c39b4dddf1df5d78258f1b98070258831b1c51c2a1116924d01508bfde563e3f5303cb50f197dfa36d5c1d775511b9f6d6f6024eab4b
7
+ data.tar.gz: 4b1a37cc4dba262c158d920e0879f07943ffc84218d7aa68207aff72539171d4f8391556acafb6ad7f3f5e070df608e5404cbb2f5c7e5d0240ee81202594e8f4
data/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented here.
4
4
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [2.0.1] - 2026-10-09
7
+
8
+ ### Fixed
9
+
10
+ - JSON-LD and web app manifests containing duplicated keys or comments are parsed again with `json` 3, which rejects them by default.
11
+
12
+ ### Changed
13
+
14
+ - CI tests the minimum supported dependency versions (`gemfiles/minimum.gemfile`, Ruby 3.2) and Dependabot is enabled.
15
+ - Gem metadata: removed the `homepage_uri` duplicate of `source_code_uri`.
16
+
6
17
  ## [2.0.0] - 2026-10-02
7
18
 
8
19
  Rewrite focused on picking the right icon, speed and safety. Breaking changes: see *Upgrading*.
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ # typed: strict
3
+
4
+ require 'json'
5
+
6
+ module BrandLogo
7
+ module LenientJson
8
+ extend T::Sig
9
+
10
+ # json >= 3 rejects duplicate keys and comments by default; json 2.x ignores these options.
11
+ OPTIONS = T.let({ allow_duplicate_key: true, allow_comments: true }.freeze, T::Hash[Symbol, T::Boolean])
12
+
13
+ sig { params(text: String).returns(T.untyped) }
14
+ def self.parse(text)
15
+ JSON.parse(text, **OPTIONS)
16
+ end
17
+ end
18
+ end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  # typed: strict
3
3
 
4
- require 'json'
5
-
6
4
  module BrandLogo
7
5
  module Strategies
8
6
  class JsonLd
@@ -25,7 +23,7 @@ module BrandLogo
25
23
 
26
24
  logos = []
27
25
  page.document.css('script[type="application/ld+json"]').each do |script|
28
- collect(JSON.parse(script.text), false, logos)
26
+ collect(LenientJson.parse(script.text), false, logos)
29
27
  rescue JSON::ParserError => e
30
28
  Logging.logger.warn("JsonLd: invalid JSON at #{page.url}: #{e.message}")
31
29
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  # typed: strict
3
3
 
4
- require 'json'
5
-
6
4
  module BrandLogo
7
5
  module Strategies
8
6
  class Manifest
@@ -31,7 +29,7 @@ module BrandLogo
31
29
 
32
30
  sig { params(response: Http::Response).returns(T::Array[T.untyped]) }
33
31
  def parse(response)
34
- data = JSON.parse(response.body)
32
+ data = LenientJson.parse(response.body)
35
33
  icons = data['icons'] if data.is_a?(::Hash)
36
34
  icons.is_a?(::Array) ? icons : []
37
35
  rescue JSON::ParserError => e
@@ -2,5 +2,5 @@
2
2
  # typed: strict
3
3
 
4
4
  module BrandLogo
5
- VERSION = '2.0.0'
5
+ VERSION = '2.0.1'
6
6
  end
data/lib/brand_logo.rb CHANGED
@@ -20,6 +20,7 @@ require_relative 'brand_logo/http/client'
20
20
  require_relative 'brand_logo/http/url_guard'
21
21
  require_relative 'brand_logo/http/real_client'
22
22
 
23
+ require_relative 'brand_logo/lenient_json'
23
24
  require_relative 'brand_logo/url_resolver'
24
25
  require_relative 'brand_logo/image_probe'
25
26
  require_relative 'brand_logo/page'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brand_logo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AdVitam
@@ -105,6 +105,7 @@ files:
105
105
  - lib/brand_logo/icon.rb
106
106
  - lib/brand_logo/image_format.rb
107
107
  - lib/brand_logo/image_probe.rb
108
+ - lib/brand_logo/lenient_json.rb
108
109
  - lib/brand_logo/logging.rb
109
110
  - lib/brand_logo/lookup.rb
110
111
  - lib/brand_logo/page.rb
@@ -126,7 +127,6 @@ licenses:
126
127
  - MIT
127
128
  metadata:
128
129
  rubygems_mfa_required: 'true'
129
- homepage_uri: https://github.com/AdVitam/brand_logo
130
130
  source_code_uri: https://github.com/AdVitam/brand_logo
131
131
  changelog_uri: https://github.com/AdVitam/brand_logo/blob/master/CHANGELOG.md
132
132
  bug_tracker_uri: https://github.com/AdVitam/brand_logo/issues