xml escape things

This commit is contained in:
maxwell 2010-12-15 18:05:09 -08:00
parent cb5982704e
commit 8d91771cb2
2 changed files with 5 additions and 12 deletions

View file

@ -31,7 +31,7 @@ module Diaspora
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
<generator uri="http://joindiaspora.com/">Diaspora</generator>
<id>#{@user.public_url}.atom</id>
<title>#{x@user.name)}'s Public Feed</title>
<title>#{x(@user.name)}'s Public Feed</title>
<subtitle>Posts from Diaspora</subtitle>
<updated>#{Time.now.xmlschema}</updated>
<author>

View file

@ -4,24 +4,17 @@
module Diaspora
module Webhooks
require 'builder/xchar'
def to_diaspora_xml
xml = "<XML>"
xml += "<post>#{to_xml.to_s}</post>"
xml += "</XML>"
end
def x(input)
result.gsub!(/[&<>'"]/) do | match |
case match
when '&' then return '&amp;'
when '<' then return '&lt;'
when '>' then return '&gt;'
when "'" then return '&apos;'
when '"' then return '&quote;'
end
end
return result
input.to_s.to_xs
end
end
end