kete-feedzirra 0.0.18.1 → 0.0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/core_ext/string.rb +1 -1
- data/lib/feedzirra.rb +2 -2
- data/lib/feedzirra/feed_utilities.rb +18 -18
- data/spec/feedzirra/feed_entry_utilities_spec.rb +7 -7
- metadata +8 -7
data/lib/core_ext/string.rb
CHANGED
data/lib/feedzirra.rb
CHANGED
@@ -5,7 +5,7 @@ gem 'activesupport'
|
|
5
5
|
require 'zlib'
|
6
6
|
require 'curb'
|
7
7
|
require 'sax-machine'
|
8
|
-
require '
|
8
|
+
require 'loofah'
|
9
9
|
require 'uri'
|
10
10
|
require 'active_support/basic_object'
|
11
11
|
require 'active_support/core_ext/object'
|
@@ -30,5 +30,5 @@ require 'feedzirra/parser/atom'
|
|
30
30
|
require 'feedzirra/parser/atom_feed_burner'
|
31
31
|
|
32
32
|
module Feedzirra
|
33
|
-
VERSION = "0.0.
|
33
|
+
VERSION = "0.0.20.1"
|
34
34
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Feedzirra
|
2
2
|
module FeedUtilities
|
3
|
-
UPDATABLE_ATTRIBUTES = %w(title feed_url url last_modified)
|
4
|
-
|
3
|
+
UPDATABLE_ATTRIBUTES = %w(title feed_url url last_modified etag)
|
4
|
+
|
5
5
|
attr_writer :new_entries, :updated, :last_modified
|
6
6
|
attr_accessor :etag
|
7
7
|
|
@@ -11,50 +11,50 @@ module Feedzirra
|
|
11
11
|
entry ? entry.published : nil
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def updated?
|
16
16
|
@updated
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def new_entries
|
20
20
|
@new_entries ||= []
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def has_new_entries?
|
24
24
|
new_entries.size > 0
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def update_from_feed(feed)
|
28
28
|
self.new_entries += find_new_entries_for(feed)
|
29
29
|
self.entries.unshift(*self.new_entries)
|
30
|
-
|
31
|
-
updated
|
30
|
+
|
31
|
+
@updated = false
|
32
|
+
UPDATABLE_ATTRIBUTES.each do |name|
|
33
|
+
@updated ||= update_attribute(feed, name)
|
34
|
+
end
|
32
35
|
end
|
33
|
-
|
36
|
+
|
34
37
|
def update_attribute(feed, name)
|
35
38
|
old_value, new_value = send(name), feed.send(name)
|
36
|
-
|
39
|
+
|
37
40
|
if old_value != new_value
|
38
41
|
send("#{name}=", new_value)
|
39
42
|
end
|
40
43
|
end
|
41
|
-
|
44
|
+
|
42
45
|
def sanitize_entries!
|
43
46
|
entries.each {|entry| entry.sanitize!}
|
44
47
|
end
|
45
|
-
|
48
|
+
|
46
49
|
private
|
47
|
-
|
48
|
-
def updated!
|
49
|
-
@updated = true
|
50
|
-
end
|
51
|
-
|
50
|
+
|
52
51
|
def find_new_entries_for(feed)
|
53
52
|
# this implementation is a hack, which is why it's so ugly.
|
54
53
|
# it's to get around the fact that not all feeds have a published date.
|
55
54
|
# however, they're always ordered with the newest one first.
|
56
55
|
# So we go through the entries just parsed and insert each one as a new entry
|
57
56
|
# until we get to one that has the same url as the the newest for the feed
|
57
|
+
return feed.entries if self.entries.length == 0
|
58
58
|
latest_entry = self.entries.first
|
59
59
|
found_new_entries = []
|
60
60
|
feed.entries.each do |entry|
|
@@ -63,7 +63,7 @@ module Feedzirra
|
|
63
63
|
end
|
64
64
|
found_new_entries
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def existing_entry?(test_entry)
|
68
68
|
entries.any? { |entry| entry.url == test_entry.url }
|
69
69
|
end
|
@@ -22,16 +22,16 @@ describe Feedzirra::FeedUtilities do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should provide a sanitized title" do
|
25
|
-
new_title = "<script>" + @entry.title
|
25
|
+
new_title = "<script>this is not safe</script>" + @entry.title
|
26
26
|
@entry.title = new_title
|
27
|
-
@entry.title.sanitize.should ==
|
27
|
+
@entry.title.sanitize.should == Loofah.scrub_fragment(new_title, :prune).to_s
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should sanitize content in place" do
|
31
31
|
new_content = "<script>" + @entry.content
|
32
32
|
@entry.content = new_content.dup
|
33
|
-
@entry.content.sanitize!.should ==
|
34
|
-
@entry.content.should ==
|
33
|
+
@entry.content.sanitize!.should == Loofah.scrub_fragment(new_content, :prune).to_s
|
34
|
+
@entry.content.should == Loofah.scrub_fragment(new_content, :prune).to_s
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should sanitize things in place" do
|
@@ -39,9 +39,9 @@ describe Feedzirra::FeedUtilities do
|
|
39
39
|
@entry.author += "<script>"
|
40
40
|
@entry.content += "<script>"
|
41
41
|
|
42
|
-
cleaned_title =
|
43
|
-
cleaned_author =
|
44
|
-
cleaned_content =
|
42
|
+
cleaned_title = Loofah.scrub_fragment(@entry.title, :prune).to_s
|
43
|
+
cleaned_author = Loofah.scrub_fragment(@entry.author, :prune).to_s
|
44
|
+
cleaned_content = Loofah.scrub_fragment(@entry.content, :prune).to_s
|
45
45
|
|
46
46
|
@entry.sanitize!
|
47
47
|
@entry.title.should == cleaned_title
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kete-feedzirra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dix
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-03 00:00:00
|
12
|
+
date: 2009-08-03 00:00:00 +12:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: 0.0.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: sax-machine
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.0.12
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: curb
|
37
37
|
type: :runtime
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,14 +63,14 @@ dependencies:
|
|
63
63
|
version: 2.0.0
|
64
64
|
version:
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
66
|
+
name: loofah
|
67
67
|
type: :runtime
|
68
68
|
version_requirement:
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.
|
73
|
+
version: 0.3.1
|
74
74
|
version:
|
75
75
|
description:
|
76
76
|
email: paul@pauldix.net
|
@@ -114,7 +114,8 @@ files:
|
|
114
114
|
- spec/feedzirra/feed_entry_utilities_spec.rb
|
115
115
|
has_rdoc: true
|
116
116
|
homepage: http://github.com/pauldix/feedzirra
|
117
|
-
licenses:
|
117
|
+
licenses: []
|
118
|
+
|
118
119
|
post_install_message:
|
119
120
|
rdoc_options: []
|
120
121
|
|