From aa6d8be6975492a40000c76e4ca5c653e1e9c268 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Wed, 23 Nov 2016 01:17:46 +0900 Subject: [PATCH] Assume that an XML declaration is at the beginning of a document --- app/models/agents/rss_agent.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/agents/rss_agent.rb b/app/models/agents/rss_agent.rb index a1ac2095..0ed34c42 100644 --- a/app/models/agents/rss_agent.rb +++ b/app/models/agents/rss_agent.rb @@ -179,7 +179,7 @@ module Agents else # Encoding is already known, so do not let the parser detect # it from the XML declaration in the content. - body.sub!(/(<\?xml(?:\s+\w+\s*=\s*(['"]).*?\2)*)\s+encoding\s*=\s*(['"]).*?\3/, '\\1') + body.sub!(/(\A\u{FEFF}?\s*<\?xml(?:\s+\w+\s*=\s*(['"]).*?\2)*)\s+encoding\s*=\s*(['"]).*?\3/, '\\1') end body end