aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/LinkUtils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-12-29 11:43:39 +0100
committerGitHub <noreply@github.com>2020-12-29 11:43:39 +0100
commit8ed5fbef8f2a5e666f80be0c38930b92672d351a (patch)
tree3198b3e164ba8ffaa8e1e947e5fa169be61674ea /application/bookmark/LinkUtils.php
parentb01b3b83a71044db833b21203dc510f9c45ad6fc (diff)
parent88a8e284b2825cbd77c75dbbbf3655a961d9eb09 (diff)
downloadShaarli-8ed5fbef8f2a5e666f80be0c38930b92672d351a.tar.gz
Shaarli-8ed5fbef8f2a5e666f80be0c38930b92672d351a.tar.zst
Shaarli-8ed5fbef8f2a5e666f80be0c38930b92672d351a.zip
Merge pull request #1665 from ArthurHoaro/fix/metadata-regexes-2
Fix metadata extract regex (2)
Diffstat (limited to 'application/bookmark/LinkUtils.php')
-rw-r--r--application/bookmark/LinkUtils.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php
index d65e97ed..0ab2d213 100644
--- a/application/bookmark/LinkUtils.php
+++ b/application/bookmark/LinkUtils.php
@@ -68,11 +68,13 @@ function html_extract_tag($tag, $html)
68 $properties = implode('|', $propertiesKey); 68 $properties = implode('|', $propertiesKey);
69 // We need a OR here to accept either 'property=og:noquote' or 'property="og:unrelated og:my-tag"' 69 // We need a OR here to accept either 'property=og:noquote' or 'property="og:unrelated og:my-tag"'
70 $orCondition = '["\']?(?:og:)?' . $tag . '["\']?|["\'][^\'"]*?(?:og:)?' . $tag . '[^\'"]*?[\'"]'; 70 $orCondition = '["\']?(?:og:)?' . $tag . '["\']?|["\'][^\'"]*?(?:og:)?' . $tag . '[^\'"]*?[\'"]';
71 // Support quotes in double quoted content, and the other way around
72 $content = 'content=(["\'])((?:(?!\1).)*)\1';
71 // Try to retrieve OpenGraph tag. 73 // Try to retrieve OpenGraph tag.
72 $ogRegex = '#<meta[^>]+(?:' . $properties . ')=(?:' . $orCondition . ')[^>]*content=(["\'])([^\1]*?)\1.*?>#'; 74 $ogRegex = '#<meta[^>]+(?:' . $properties . ')=(?:' . $orCondition . ')[^>]*' . $content . '.*?>#';
73 // If the attributes are not in the order property => content (e.g. Github) 75 // If the attributes are not in the order property => content (e.g. Github)
74 // New regex to keep this readable... more or less. 76 // New regex to keep this readable... more or less.
75 $ogRegexReverse = '#<meta[^>]+content=(["\'])([^\1]*?)\1[^>]+(?:' . $properties . ')=(?:' . $orCondition . ').*?>#'; 77 $ogRegexReverse = '#<meta[^>]+' . $content . '[^>]+(?:' . $properties . ')=(?:' . $orCondition . ').*?>#';
76 78
77 if ( 79 if (
78 preg_match($ogRegex, $html, $matches) > 0 80 preg_match($ogRegex, $html, $matches) > 0