URLEmbeddedView icon indicating copy to clipboard operation
URLEmbeddedView copied to clipboard

OG data not read properly on certain sites

Open felixdkatt opened this issue 5 years ago • 6 comments

https://theyeshiva.net returns bad data but works fine on ios iMessage app

image

also no image on https://washingtonpost.com but is ok on iMessage

here is the iMessage successful loads image

felixdkatt avatar Nov 29 '18 04:11 felixdkatt

also I used facebook open graph debugger and except for small image warning it parsed ok

https://developers.facebook.com/tools/debug/sharing/?q=theyeshiva.net

felixdkatt avatar Nov 29 '18 04:11 felixdkatt

this link.... I cant to read meta-data https://m.youtube.com/watch?v=kSUJ28rgNyo

dan085 avatar Dec 16 '18 20:12 dan085

@felixdkatt Sites you provided doesn't support OpenGraph protocol as it is. Facebook debug tool is not about OpenGraph protocol only. Facebook and iMessages do additional work on some common scenarios for sites that doesn't support OpenGraph. To check site against OpenGrpah protocol check this one: https://opengraphcheck.com/result.php?url=https%3A%2F%2Fwashingtonpost.com#.XIdnVRMzZTY https://opengraphcheck.com/result.php?url=https%3A%2F%2Ftheyeshiva.net#.XIdnZRMzZTY

Luten avatar Mar 12 '19 08:03 Luten

OK, i think i have fix for that. There are websites that are using "name" instead of "property" key in <meta ... block> Also, sometimes websites are using capital P i < meta Property > and here regular expression is caseSensitive. So here are my adjustments @marty-suzuki @felixdkatt In OpenGraph.HTML.swift change implementation of property regex like so:

static let regex: NSRegularExpression? = { let patterns = [ // "" & "" "(?:content\\s*=\\s*\"([^>]*)\"\\s*property\\s*=\\s*\"([^>]*)\")", "(?:property\\s*=\\s*\"([^>]*)\"\\s*content\\s*=\\s*\"([^>]*)\")", // name instead of property "(?:content\\s*=\\s*\"([^>]*)\"\\s*name\\s*=\\s*\"([^>]*)\")", "(?:name\\s*=\\s*\"([^>]*)\"\\s*content\\s*=\\s*\"([^>]*)\")", // '' & '' "(?:content\\s*=\\s*'([^>]*)'\\s*property\\s*=\\s*'([^>]*)')", "(?:property\\s*=\\s*'([^>]*)'\\s*content\\s*=\\s*'([^>]*)')", // "" & '' "(?:content\\s*=\\s*\"([^>]*)\"\\s*property\\s*=\\s*'([^>]*)')", "(?:property\\s*=\\s*\"([^>]*)\"\\s*content\\s*=\\s*'([^>]*)')", // '' & "" "(?:content\\s*=\\s*'([^>]*)'\\s*property\\s*=\\s*\"([^>]*)\")", "(?:property\\s*=\\s*'([^>]*)'\\s*content\\s*=\\s*\"([^>]*)\")" ] let pattern = "meta\\s*\(patterns.joined(separator: "|"))\\s*>?" return try? NSRegularExpression(pattern: pattern, options: [.caseInsensitive]) }()

H3ndrx avatar Jan 08 '20 17:01 H3ndrx

here is pull request to fix that #84 @marty-suzuki

H3ndrx avatar Jan 08 '20 17:01 H3ndrx

thank you @H3ndrx I will check it out

felixdkatt avatar Jan 08 '20 19:01 felixdkatt