twitter-text 1.2.1 → 1.2.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.
- data/Rakefile +1 -1
- data/lib/autolink.rb +5 -5
- data/spec/autolinking_spec.rb +12 -12
- metadata +4 -4
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ require 'digest'
|
|
11
11
|
|
12
12
|
spec = Gem::Specification.new do |s|
|
13
13
|
s.name = "twitter-text"
|
14
|
-
s.version = "1.2.
|
14
|
+
s.version = "1.2.2"
|
15
15
|
s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle", "Raffi Krikorian"]
|
16
16
|
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com", "raffi@twitter.com"]
|
17
17
|
s.homepage = "http://twitter.com"
|
data/lib/autolink.rb
CHANGED
@@ -24,7 +24,7 @@ module Twitter
|
|
24
24
|
"'" => '''
|
25
25
|
}
|
26
26
|
|
27
|
-
def
|
27
|
+
def html_escape(text)
|
28
28
|
text && text.gsub(/[&"'><]/) do |character|
|
29
29
|
HTML_ENTITIES[character]
|
30
30
|
end
|
@@ -88,7 +88,7 @@ module Twitter
|
|
88
88
|
# the link is a list
|
89
89
|
chunk = list = "#{user}#{slash_listname}"
|
90
90
|
chunk = yield(list) if block_given?
|
91
|
-
"#{before}#{at}<a class=\"#{options[:url_class]} #{options[:list_class]}\" href=\"#{
|
91
|
+
"#{before}#{at}<a class=\"#{options[:url_class]} #{options[:list_class]}\" href=\"#{html_escape(options[:list_url_base])}#{html_escape(list.downcase)}\"#{extra_html}>#{html_escape(chunk)}</a>"
|
92
92
|
else
|
93
93
|
if after =~ Twitter::Regex[:end_screen_name_match]
|
94
94
|
# Followed by something that means we don't autolink
|
@@ -97,7 +97,7 @@ module Twitter
|
|
97
97
|
# this is a screen name
|
98
98
|
chunk = user
|
99
99
|
chunk = yield(chunk) if block_given?
|
100
|
-
"#{before}#{at}<a class=\"#{options[:url_class]} #{options[:username_class]}\" href=\"#{
|
100
|
+
"#{before}#{at}<a class=\"#{options[:url_class]} #{options[:username_class]}\" href=\"#{html_escape(options[:username_url_base])}#{html_escape(chunk)}\"#{extra_html}>#{html_escape(chunk)}</a>"
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -126,7 +126,7 @@ module Twitter
|
|
126
126
|
hash = $2
|
127
127
|
text = $3
|
128
128
|
text = yield(text) if block_given?
|
129
|
-
"#{before}<a href=\"#{options[:hashtag_url_base]}#{
|
129
|
+
"#{before}<a href=\"#{options[:hashtag_url_base]}#{html_escape(text)}\" title=\"##{html_escape(text)}\" class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(text)}</a>"
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -143,7 +143,7 @@ module Twitter
|
|
143
143
|
if !protocol.blank? || domain =~ Twitter::Regex[:probable_tld]
|
144
144
|
html_attrs = tag_options(options.stringify_keys) || ""
|
145
145
|
full_url = ((protocol =~ Twitter::Regex[:www] || protocol.blank?) ? "http://#{url}" : url)
|
146
|
-
"#{before}<a href=\"#{
|
146
|
+
"#{before}<a href=\"#{html_escape(full_url)}\"#{html_attrs}>#{html_escape(url)}</a>"
|
147
147
|
else
|
148
148
|
all
|
149
149
|
end
|
data/spec/autolinking_spec.rb
CHANGED
@@ -518,22 +518,22 @@ describe Twitter::Autolink do
|
|
518
518
|
|
519
519
|
end
|
520
520
|
|
521
|
-
describe "
|
521
|
+
describe "html_escape" do
|
522
522
|
before do
|
523
523
|
@linker = TestAutolink.new
|
524
524
|
end
|
525
525
|
it "should escape html entities properly" do
|
526
|
-
@linker.
|
527
|
-
@linker.
|
528
|
-
@linker.
|
529
|
-
@linker.
|
530
|
-
@linker.
|
531
|
-
@linker.
|
532
|
-
@linker.
|
533
|
-
@linker.
|
534
|
-
@linker.
|
535
|
-
@linker.
|
536
|
-
@linker.
|
526
|
+
@linker.html_escape("&").should == "&"
|
527
|
+
@linker.html_escape(">").should == ">"
|
528
|
+
@linker.html_escape("<").should == "<"
|
529
|
+
@linker.html_escape("\"").should == """
|
530
|
+
@linker.html_escape("'").should == "'"
|
531
|
+
@linker.html_escape("&<>\"").should == "&<>""
|
532
|
+
@linker.html_escape("<div>").should == "<div>"
|
533
|
+
@linker.html_escape("a&b").should == "a&b"
|
534
|
+
@linker.html_escape("<a href=\"http://twitter.com\" target=\"_blank\">twitter & friends</a>").should == "<a href="http://twitter.com" target="_blank">twitter & friends</a>"
|
535
|
+
@linker.html_escape("&").should == "&amp;"
|
536
|
+
@linker.html_escape(nil).should == nil
|
537
537
|
end
|
538
538
|
end
|
539
539
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Sanford
|
@@ -19,7 +19,7 @@ autorequire: ""
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-10-
|
22
|
+
date: 2010-10-08 00:00:00 -07:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|