소스 검색

Merge pull request #1337 from Alkarex/SimplePie-feed_or_html-UTF8-BOM

Add support for UTF-8 BOM in SimplePie feed_or_html()
Alexandre Alapetite 9 년 전
부모
커밋
40b5d3f933
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      lib/SimplePie/SimplePie/Content/Type/Sniffer.php

+ 6 - 1
lib/SimplePie/SimplePie/Content/Type/Sniffer.php

@@ -256,7 +256,12 @@ class SimplePie_Content_Type_Sniffer
 	public function feed_or_html()
 	{
 		$len = strlen($this->file->body);
-		$pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
+		$pos = 0;
+		if (isset($this->file->body[2]) && $this->file->body[0] === "\xEF" &&
+			$this->file->body[1] === "\xBB" && $this->file->body[2] === "\xBF") {
+			$pos += 3;	//UTF-8 BOM
+		}
+		$pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
 
 		while ($pos < $len)
 		{