couple of bugfixes identified while importing from VB

This commit is contained in:
Régis Hanol 2014-03-07 10:44:04 +01:00
parent 7670598658
commit f25bcc5067
5 changed files with 15 additions and 11 deletions

View File

@ -75,7 +75,7 @@ class PostAnalyzer
begin
uri = URI.parse(u)
host = uri.host
@linked_hosts[host] ||= 1
@linked_hosts[host] ||= 1 unless host.nil?
rescue URI::InvalidURIError
# An invalid URI does not count as a raw link.
next
@ -90,10 +90,10 @@ class PostAnalyzer
return [] unless @raw.present?
return @raw_links if @raw_links.present?
# Don't include @mentions in the link count
@raw_links = []
cooked_document.search("a").each do |l|
# Don't include @mentions in the link count
next if l.attributes['href'].nil? || link_is_a_mention?(l)
url = l.attributes['href'].to_s
@raw_links << url

View File

@ -192,7 +192,7 @@ module PrettyText
else
l["rel"] = "nofollow"
end
rescue URI::InvalidURIError
rescue URI::InvalidURIError, URI::InvalidComponentError
# add a nofollow anyway
l["rel"] = "nofollow"
end

View File

@ -437,11 +437,15 @@
};
function escapeHTML( text ) {
if (text && text.length > 0) {
return text.replace( /&/g, "&amp;" )
.replace( /</g, "&lt;" )
.replace( />/g, "&gt;" )
.replace( /"/g, "&quot;" )
.replace( /'/g, "&#39;" );
} else {
return "";
}
}
function render_tree( jsonml ) {