pauldix-feedzirra 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +4 -5
- data/lib/feedzirra/feed_entry_utilities.rb +23 -14
- data/lib/feedzirra.rb +1 -1
- data/spec/feedzirra/feed_entry_utilities_spec.rb +8 -1
- metadata +2 -2
data/README.textile
CHANGED
@@ -77,9 +77,10 @@ entry.published # => Thu Jan 29 17:00:19 UTC 2009 # it's a Time object
|
|
77
77
|
entry.categories # => ["...", "..."]
|
78
78
|
|
79
79
|
# sanitizing an entry's content
|
80
|
-
entry.
|
81
|
-
entry.
|
82
|
-
entry.
|
80
|
+
entry.title.sanitize # => returns the title with harmful stuff escaped
|
81
|
+
entry.author.sanitize # => returns the author with harmful stuff escaped
|
82
|
+
entry.content.sanitize # => returns the content with harmful stuff escaped
|
83
|
+
entry.content.sanitize! # => returns content with harmful stuff escaped and replaces original (also exists for author and title)
|
83
84
|
entry.sanitize! # => sanitizes the entry's title, author, and content in place (as in, it changes the value to clean versions)
|
84
85
|
feed.sanitize_entries! # => sanitizes all entries in place
|
85
86
|
|
@@ -139,8 +140,6 @@ This thing needs to hammer on many different feeds in the wild. I'm sure there w
|
|
139
140
|
|
140
141
|
Here are some more specific TODOs.
|
141
142
|
* Make a feedzirra-rails gem to integrate feedzirra seamlessly with Rails and ActiveRecord.
|
142
|
-
* Add function to sanitize content.
|
143
|
-
* Add support to automatically handle gzip and deflate encododing.
|
144
143
|
* Add support for authenticated feeds.
|
145
144
|
* Create a super sweet DSL for defining new parsers.
|
146
145
|
* Test against Ruby 1.9.1 and fix any bugs.
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Feedzirra
|
2
2
|
module FeedEntryUtilities
|
3
|
+
module Sanitize
|
4
|
+
def sanitize!
|
5
|
+
self.replace(sanitize)
|
6
|
+
end
|
7
|
+
|
8
|
+
def sanitize
|
9
|
+
Dryopteris.sanitize(self)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
attr_reader :published
|
4
14
|
|
5
15
|
def parse_datetime(string)
|
@@ -10,23 +20,22 @@ module Feedzirra
|
|
10
20
|
@published = parse_datetime(val)
|
11
21
|
end
|
12
22
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
dispatcher.new(self)
|
23
|
+
def content
|
24
|
+
@content.extend(Sanitize)
|
25
|
+
end
|
26
|
+
|
27
|
+
def title
|
28
|
+
@title.extend(Sanitize)
|
29
|
+
end
|
30
|
+
|
31
|
+
def author
|
32
|
+
@author.extend(Sanitize)
|
24
33
|
end
|
25
34
|
|
26
35
|
def sanitize!
|
27
|
-
self.title
|
28
|
-
self.author
|
29
|
-
self.content
|
36
|
+
self.title.sanitize!
|
37
|
+
self.author.sanitize!
|
38
|
+
self.content.sanitize!
|
30
39
|
end
|
31
40
|
|
32
41
|
alias_method :last_modified, :published
|
data/lib/feedzirra.rb
CHANGED
@@ -24,7 +24,14 @@ describe Feedzirra::FeedUtilities do
|
|
24
24
|
it "should provide a sanitized title" do
|
25
25
|
new_title = "<script>" + @entry.title
|
26
26
|
@entry.title = new_title
|
27
|
-
@entry.
|
27
|
+
@entry.title.sanitize.should == Dryopteris.sanitize(new_title)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should sanitize content in place" do
|
31
|
+
new_content = "<script>" + @entry.content
|
32
|
+
@entry.content = new_content.dup
|
33
|
+
@entry.content.sanitize!.should == Dryopteris.sanitize(new_content)
|
34
|
+
@entry.content.should == Dryopteris.sanitize(new_content)
|
28
35
|
end
|
29
36
|
|
30
37
|
it "should sanitize things in place" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pauldix-feedzirra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dix
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.9
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: taf2-curb
|