X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Fbookmark%2FLinkUtils.php;h=cf97e3b0a904a08d72a5ee7d3467efb1536f5c96;hb=d9d71b10c3bc70a0881d630b37dc4e918c9e812f;hp=9493b0aa894e00de160684be54dc3f8ab4aa4bab;hpb=8a1ce1da15fdbae99b24700b06f2008c7a657603;p=github%2Fshaarli%2FShaarli.git
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php
index 9493b0aa..cf97e3b0 100644
--- a/application/bookmark/LinkUtils.php
+++ b/application/bookmark/LinkUtils.php
@@ -68,16 +68,16 @@ function html_extract_tag($tag, $html)
$properties = implode('|', $propertiesKey);
// We need a OR here to accept either 'property=og:noquote' or 'property="og:unrelated og:my-tag"'
$orCondition = '["\']?(?:og:)?'. $tag .'["\']?|["\'][^\'"]*?(?:og:)?' . $tag . '[^\'"]*?[\'"]';
- // Try to retrieve OpenGraph image.
- $ogRegex = '#]+(?:'. $properties .')=(?:'. $orCondition .')[^>]*content=["\'](.*?)["\'].*?>#';
+ // Try to retrieve OpenGraph tag.
+ $ogRegex = '#]+(?:'. $properties .')=(?:'. $orCondition .')[^>]*content=(["\'])([^\1]*?)\1.*?>#';
// If the attributes are not in the order property => content (e.g. Github)
// New regex to keep this readable... more or less.
- $ogRegexReverse = '#]+content=["\'](.*?)["\'][^>]+(?:'. $properties .')=(?:'. $orCondition .').*?>#';
+ $ogRegexReverse = '#]+content=(["\'])([^\1]*?)\1[^>]+(?:'. $properties .')=(?:'. $orCondition .').*?>#';
if (preg_match($ogRegex, $html, $matches) > 0
|| preg_match($ogRegexReverse, $html, $matches) > 0
) {
- return $matches[1];
+ return $matches[2];
}
return false;