feedjira 4.0.0 → 4.0.2

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: 8c0d5191e078e304c8167c6a751183e9fc696180d46197cd27514412a1b19ee7
4
- data.tar.gz: 7468bd2d9e312250a8d01410b0934877566ebd924ff50d369d25faa0f9c9c285
3
+ metadata.gz: cb65081b36daffe6b574820cdfba4b0e444854e8e72b3b6f6f82f2efc80befd2
4
+ data.tar.gz: 14d58fb668a54606e0b03e0f8f9a6748681a562902955120937f0cb6cd62c0b7
5
5
  SHA512:
6
- metadata.gz: 6db87062df76ea36471ae9c39502e7be29ccdbd317aa7fa1f9dd914cab6294a23ff0d154ee3578b101fecf4d6908dc0e800e44a5b7ef986e4af8d4ff320ad941
7
- data.tar.gz: 0351de63585571aaac4742d475ae32700f701158a35e6d3f768edf79629c4172d99ec3e30be194dc067d722437fdd9be7b089faf8e6f35b0965c748253ff9aee
6
+ metadata.gz: 39be37b94a2c07856bee078fa641015ce78c19336797dbf1403d731db27b6c2ab44ad834e2b691c63b9d473462e1794b228e949e7b87d7647a04c198ab514274
7
+ data.tar.gz: 0c9237598fd8d7cea5be2201169925d30983298b02612d2812fd1ab196337be4b5a5054eb5f58430b8a4f3bfe6465f4a8018064539bcb93779d12802d9371248
data/.rubocop.yml CHANGED
@@ -60,3 +60,6 @@ RSpec/RepeatedExample:
60
60
  Enabled: false
61
61
 
62
62
  Style/Copyright: { Enabled: false }
63
+
64
+ Style/HashLookupMethod:
65
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,14 +1,13 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
3
- # on 2025-08-24 01:08:06 UTC using RuboCop version 1.79.1.
3
+ # on 2025-09-02 06:40:19 UTC using RuboCop version 1.80.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 12
10
- # Configuration parameters: Include, IgnoredGems, OnlyFor.
11
- # Include: **/*.gemfile, **/Gemfile, **/gems.rb
10
+ # Configuration parameters: IgnoredGems, OnlyFor.
12
11
  Bundler/GemComment:
13
12
  Exclude:
14
13
  - 'Gemfile'
@@ -75,7 +74,7 @@ Layout/SingleLineBlockChain:
75
74
  - 'spec/feedjira/feed_utilities_spec.rb'
76
75
  - 'spec/feedjira/parser/atom_feed_burner_spec.rb'
77
76
 
78
- # Offense count: 355
77
+ # Offense count: 364
79
78
  # Configuration parameters: Only, Ignore.
80
79
  Lint/ConstantResolution:
81
80
  Exclude:
@@ -154,6 +153,12 @@ Lint/NumberConversion:
154
153
  Exclude:
155
154
  - 'lib/feedjira/parser/podlove_chapter.rb'
156
155
 
156
+ # Offense count: 1
157
+ # Configuration parameters: CountComments, Max, CountAsOne.
158
+ Metrics/ModuleLength:
159
+ Exclude:
160
+ - 'spec/feedjira/parser/atom_spec.rb'
161
+
157
162
  # Offense count: 1
158
163
  # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
159
164
  # AllowedMethods: call
@@ -285,7 +290,7 @@ Style/InlineComment:
285
290
  - 'spec/feedjira/feed_utilities_spec.rb'
286
291
  - 'spec/feedjira/preprocessor_spec.rb'
287
292
 
288
- # Offense count: 881
293
+ # Offense count: 890
289
294
  # This cop supports safe autocorrection (--autocorrect).
290
295
  # Configuration parameters: IgnoreMacros, AllowedMethods, AllowedPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle.
291
296
  # SupportedStyles: require_parentheses, omit_parentheses
@@ -389,9 +394,3 @@ Style/StringHashKeys:
389
394
  Style/SuperArguments:
390
395
  Exclude:
391
396
  - 'lib/feedjira/feed_utilities.rb'
392
-
393
- # Offense count: 1
394
- # This cop supports safe autocorrection (--autocorrect).
395
- Style/SuperWithArgsParentheses:
396
- Exclude:
397
- - 'lib/feedjira/feed_utilities.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Feedjira Changelog
2
2
 
3
+ ## 4.0.2
4
+
5
+ * Fix ITunesRSS.able_to_parse? false positive on CDATA content (#570)
6
+
7
+ ## 4.0.1
8
+
9
+ * Amend Atom parser able_to_parse regex to also match the HTTPS variant of the xmlns attribute value (#558)
10
+
3
11
  ## 4.0.0
4
12
 
5
13
  * Drop support for Ruby 2.7 and 3.0 (#555)
data/Gemfile CHANGED
@@ -4,13 +4,13 @@ source "https://rubygems.org/"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "faraday", "~> 2.8.1"
8
- gem "pry", "~> 0.15.0"
7
+ gem "faraday", "~> 2.14.0"
8
+ gem "pry", "~> 0.16.0"
9
9
  gem "rspec", "~> 3.13.0"
10
- gem "rubocop", "~> 1.79.0"
11
- gem "rubocop-performance", "~> 1.25.0"
10
+ gem "rubocop", "~> 1.86.0"
11
+ gem "rubocop-performance", "~> 1.26.0"
12
12
  gem "rubocop-rake", "~> 0.7.1"
13
- gem "rubocop-rspec", "~> 3.6.0"
13
+ gem "rubocop-rspec", "~> 3.9.0"
14
14
  gem "simplecov", "~> 0.22.0"
15
15
  gem "yard", "~> 0.9.34"
16
16
 
@@ -17,7 +17,7 @@ module Feedjira
17
17
  element :icon
18
18
 
19
19
  def self.able_to_parse?(xml)
20
- %r{<feed[^>]+xmlns\s?=\s?["'](http://www\.w3\.org/2005/Atom|http://purl\.org/atom/ns\#)["'][^>]*>} =~ xml
20
+ %r{<feed[^>]+xmlns\s?=\s?["'](https?://www\.w3\.org/2005/Atom|http://purl\.org/atom/ns\#)["'][^>]*>} =~ xml
21
21
  end
22
22
 
23
23
  def url
@@ -15,7 +15,7 @@ module Feedjira
15
15
  elements :entry, as: :entries, class: AtomGoogleAlertsEntry
16
16
 
17
17
  def self.able_to_parse?(xml)
18
- Atom.able_to_parse?(xml) && (%r{<id>tag:google\.com,2005:[^<]+/com\.google/alerts/} === xml) # rubocop:disable Style/CaseEquality
18
+ Atom.able_to_parse?(xml) && (%r{<id>tag:google\.com,2005:[^<]+/com\.google/alerts/} === xml)
19
19
  end
20
20
 
21
21
  def self.preprocess(xml)
@@ -63,7 +63,8 @@ module Feedjira
63
63
  elements :item, as: :entries, class: ITunesRSSItem
64
64
 
65
65
  def self.able_to_parse?(xml)
66
- %r{xmlns:itunes\s?=\s?["']http://www\.itunes\.com/dtds/podcast-1\.0\.dtd["']}i =~ xml
66
+ xml_without_cdata = xml.gsub(/<!\[CDATA\[.*?\]\]>/m, "")
67
+ %r{xmlns:itunes\s?=\s?["']http://www\.itunes\.com/dtds/podcast-1\.0\.dtd["']}i =~ xml_without_cdata
67
68
  end
68
69
  end
69
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Feedjira
4
- VERSION = "4.0.0"
4
+ VERSION = "4.0.2"
5
5
  end
data/lib/feedjira.rb CHANGED
@@ -44,7 +44,8 @@ require_relative "feedjira/parser/json_feed_item"
44
44
 
45
45
  # Feedjira
46
46
  module Feedjira
47
- NoParserAvailable = Class.new(StandardError)
47
+ class NoParserAvailable < StandardError
48
+ end
48
49
 
49
50
  extend Configuration
50
51
 
@@ -4,21 +4,72 @@ require "spec_helper"
4
4
 
5
5
  module Feedjira
6
6
  module Parser
7
- describe "#will_parse?" do
8
- it "returns true for an atom feed" do
9
- expect(Atom).to be_able_to_parse(sample_atom_feed)
7
+ describe "#able_to_parse?" do
8
+ it "returns false if the xmlns value is not the expected value" do
9
+ xml = '<feed xmlns="http://www.example.org/"></feed>'
10
+ expect(Atom).not_to be_able_to_parse(xml)
10
11
  end
11
12
 
12
- it "returns false for an rdf feed" do
13
- expect(Atom).not_to be_able_to_parse(sample_rdf_feed)
13
+ it "returns false if there is no xmlns value" do
14
+ xml = "<feed></feed>"
15
+ expect(Atom).not_to be_able_to_parse(xml)
14
16
  end
15
17
 
16
- it "returns false for an rss feedburner feed" do
17
- expect(Atom).not_to be_able_to_parse(sample_rss_feed_burner_feed)
18
+ describe "with a w3.org URL present" do
19
+ it "returns true if contains the expected w3.org URL as xmlns value" do
20
+ xml = '<feed xmlns="http://www.w3.org/2005/Atom"></feed>'
21
+ expect(Atom).to be_able_to_parse(xml)
22
+ end
23
+
24
+ it "returns true if contains the HTTPS variant of the expected w3.org URL as xmlns value" do
25
+ xml = '<feed xmlns="https://www.w3.org/2005/Atom"></feed>'
26
+ expect(Atom).to be_able_to_parse(xml)
27
+ end
28
+
29
+ it "returns true if contains the expected xmlns value with single quotes" do
30
+ xml = "<feed xmlns='http://www.w3.org/2005/Atom'></feed>"
31
+ expect(Atom).to be_able_to_parse(xml)
32
+ end
33
+
34
+ it "returns true with whitespace around the equals sign" do
35
+ xml = '<feed xmlns = "http://www.w3.org/2005/Atom"></feed>'
36
+ expect(Atom).to be_able_to_parse(xml)
37
+ end
38
+ end
39
+
40
+ describe "with a purl.org URL present" do
41
+ it "returns true if contains the expected purl.org URL as xmlns value" do
42
+ xml = '<feed xmlns="http://purl.org/atom/ns#"></feed>'
43
+ expect(Atom).to be_able_to_parse(xml)
44
+ end
45
+
46
+ it "returns true if contains the expected xmlns value with single quotes" do
47
+ xml = "<feed xmlns='http://purl.org/atom/ns#'></feed>"
48
+ expect(Atom).to be_able_to_parse(xml)
49
+ end
50
+
51
+ it "returns true with whitespace around the equals sign" do
52
+ xml = '<feed xmlns = "http://purl.org/atom/ns#"></feed>'
53
+ expect(Atom).to be_able_to_parse(xml)
54
+ end
18
55
  end
19
56
 
20
- it "returns true for an atom feed that has line breaks in between attributes in the <feed> node" do
21
- expect(Atom).to be_able_to_parse(sample_atom_feed_line_breaks)
57
+ context "with full sample feeds" do
58
+ it "returns true for an atom feed" do
59
+ expect(Atom).to be_able_to_parse(sample_atom_feed)
60
+ end
61
+
62
+ it "returns false for an rdf feed" do
63
+ expect(Atom).not_to be_able_to_parse(sample_rdf_feed)
64
+ end
65
+
66
+ it "returns false for an rss feedburner feed" do
67
+ expect(Atom).not_to be_able_to_parse(sample_rss_feed_burner_feed)
68
+ end
69
+
70
+ it "returns true for an atom feed that has line breaks in between attributes in the <feed> node" do
71
+ expect(Atom).to be_able_to_parse(sample_atom_feed_line_breaks)
72
+ end
22
73
  end
23
74
  end
24
75
 
@@ -24,6 +24,10 @@ module Feedjira
24
24
  it "returns false for an rss feedburner feed" do
25
25
  expect(ITunesRSS).not_to be_able_to_parse(sample_rss_feed_burner_feed)
26
26
  end
27
+
28
+ it "returns false for an atom feed with xmlns:itunes inside CDATA" do
29
+ expect(ITunesRSS).not_to be_able_to_parse(sample_atom_with_itunes_in_cdata)
30
+ end
27
31
  end
28
32
 
29
33
  describe "parsing" do
@@ -155,6 +155,12 @@ RSpec.describe Feedjira do
155
155
  expect(actual_parser).to eq described_class::Parser::ITunesRSS
156
156
  end
157
157
 
158
+ it "with an atom feed containing xmlns:itunes in CDATA it returns the Atom parser" do
159
+ xml = sample_atom_with_itunes_in_cdata
160
+ actual_parser = described_class.parser_for_xml(xml)
161
+ expect(actual_parser).to eq described_class::Parser::Atom
162
+ end
163
+
158
164
  context "when parsers are configured" do
159
165
  it "does not use default parsers" do
160
166
  xml = "Atom asdf"
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom">
3
+ <title>Test Blog</title>
4
+ <link rel="alternate" href="https://example.com/" />
5
+ <id>tag:example.com,2024:blog</id>
6
+ <updated>2024-01-01T00:00:00Z</updated>
7
+ <entry>
8
+ <title>How to set up a podcast RSS feed</title>
9
+ <link href="https://example.com/post/1" />
10
+ <id>tag:example.com,2024:post-1</id>
11
+ <published>2024-01-01T00:00:00Z</published>
12
+ <content type="html"><![CDATA[
13
+ <p>Here is an example RSS feed:</p>
14
+ <pre><code>&lt;rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"&gt;</code></pre>
15
+ ]]></content>
16
+ </entry>
17
+ </feed>
data/spec/sample_feeds.rb CHANGED
@@ -37,7 +37,8 @@ module SampleFeeds
37
37
  sample_invalid_date_format_feed: "InvalidDateFormat.xml",
38
38
  sample_rss_feed_permalinks: "Permalinks.xml",
39
39
  sample_rss_feed_with_a10_namespace: "a10.xml",
40
- sample_rss_feed_with_comments: "RSSWithComments.xml"
40
+ sample_rss_feed_with_comments: "RSSWithComments.xml",
41
+ sample_atom_with_itunes_in_cdata: "AtomWithITunesInCDATA.xml"
41
42
  }.freeze
42
43
 
43
44
  FEEDS.each do |method, filename|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hess
@@ -164,6 +164,7 @@ files:
164
164
  - spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml
165
165
  - spec/sample_feeds/AtomEscapedHTMLInPreTag.xml
166
166
  - spec/sample_feeds/AtomFeedWithSpacesAroundEquals.xml
167
+ - spec/sample_feeds/AtomWithITunesInCDATA.xml
167
168
  - spec/sample_feeds/CRE.xml
168
169
  - spec/sample_feeds/DuplicateContentAtomFeed.xml
169
170
  - spec/sample_feeds/FeedBurnerUrlNoAlternate.xml
@@ -226,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
227
  - !ruby/object:Gem::Version
227
228
  version: '0'
228
229
  requirements: []
229
- rubygems_version: 3.6.9
230
+ rubygems_version: 4.0.10
230
231
  specification_version: 4
231
232
  summary: A feed parsing library
232
233
  test_files: []