From ca3d082b26bea0a1345483c62365379b345be546 Mon Sep 17 00:00:00 2001 From: Miroslav Kucera Date: Fri, 20 Mar 2015 12:57:31 +0100 Subject: [PATCH] No need to scan all string to find starting substring match --- OpenGraph.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenGraph.php b/OpenGraph.php index af2e7b6..0ec8a0f 100644 --- a/OpenGraph.php +++ b/OpenGraph.php @@ -97,14 +97,14 @@ static private function _parse($HTML) { foreach ($tags AS $tag) { if ($tag->hasAttribute('property') && - strpos($tag->getAttribute('property'), 'og:') === 0) { + strncmp($tag->getAttribute('property'), 'og:', 3) === 0) { $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); $page->_values[$key] = $tag->getAttribute('content'); } //Added this if loop to retrieve description values from sites like the New York Times who have malformed it. if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') && - strpos($tag->getAttribute('property'), 'og:') === 0) { + strncmp($tag->getAttribute('property'), 'og:', 3) === 0) { $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); $page->_values[$key] = $tag->getAttribute('value'); }