File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ protected function getThumbLinkFromUrl(string $url): string
7979 return '' ;
8080 }
8181
82- $ link = $ linkMatches [1 ];
82+ $ link = html_entity_decode ( $ linkMatches [1 ]) ;
8383
8484 if (!str_starts_with ($ link , 'https:// ' ) && !str_starts_with ($ link , 'http:// ' )) {
8585 return '' ;
Original file line number Diff line number Diff line change @@ -40,4 +40,28 @@ public function test_successful_fetch()
4040
4141 unlink ($ expectedPath );
4242 }
43+
44+ public function test_html_encoding_in_opengraph_url_is_decoded ()
45+ {
46+ $ imageData = base64_decode ('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg== ' );
47+ Http::fake ([
48+ 'example.com/* ' => Http::response (<<<END
49+ <html>
50+ <head>
51+ <meta property="og:image" content="https://exampleb.com/image.png?a=b&c=d">
52+ </head>
53+ </html>
54+ END ),
55+ 'https://exampleb.com/image.png?a=b&c=d ' => Http::response ($ imageData ),
56+ 'exampleb.com/* ' => Http::response ('' , 404 ),
57+ ]);
58+ $ post = Post::factory ()->create (['url ' => 'http://example.com/cats ' ]);
59+
60+ $ fetcher = new PostThumbnailFetcher ();
61+ $ result = $ fetcher ->fetchAndStoreForPost ($ post );
62+ $ this ->assertTrue ($ result );
63+
64+ $ expectedPath = storage_path ("app/public/thumbs/ {$ post ->feed_id }/ {$ post ->id }.png " );
65+ unlink ($ expectedPath );
66+ }
4367}
You can’t perform that action at this time.
0 commit comments