From: lain Date: Sat, 22 Jun 2019 14:22:59 +0000 (+0200) Subject: Rich Media Parser: Do not return just a title if nothing else is there. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0e415921cd46c2efdc551bc7bcff6fd7f1123735;p=akkoma Rich Media Parser: Do not return just a title if nothing else is there. --- diff --git a/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex b/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex index 82f1cce29..fb79630e4 100644 --- a/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex +++ b/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex @@ -34,13 +34,15 @@ defmodule Pleroma.Web.RichMedia.Parsers.MetaTagsParser do defp maybe_put_title(%{title: _} = meta, _), do: meta - defp maybe_put_title(meta, html) do + defp maybe_put_title(meta, html) when meta != %{} do case get_page_title(html) do "" -> meta title -> Map.put_new(meta, :title, title) end end + defp maybe_put_title(meta, _), do: meta + defp get_page_title(html) do Floki.find(html, "title") |> Floki.text() end diff --git a/test/fixtures/rich_media/non_ogp_embed.html b/test/fixtures/rich_media/non_ogp_embed.html new file mode 100644 index 000000000..62a1d677a --- /dev/null +++ b/test/fixtures/rich_media/non_ogp_embed.html @@ -0,0 +1,1479 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BlueAngelLove's Homepage on MyFreeCams.com + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + + + + + +
Your Time:
MyFreeCams Time:
+
+ +
+
+ +
+
+
+
+
+ +
+ +
+ +
+
+ BlueAngelLove +
+ +
+
+ Status: +
+
+ +  - Model - + +
+
+ + + +
+ + Profile Headline: + + + + Enjoy and Love + +
+ + + + + + + + +
+ + Last Broadcast: + + + +
+ + + + + +
+ + Last Updated: + + + +
+ + + +
+
+
+
+ +
+ +
+
+
+
+ + +
+ My Most Recent Pictures +
+
+ +
+
+
+
+ +
+
+
+ +
+ +
+ About Me +
+ + + +
+ + Username: + + + + BlueAngelLove +
+ + + + + + + + +
+ + Gender: + + + + Female +
+ + + + + +
+ + Body Type: + + + + Athletic +
+ + + + + +
+ + Ethnicity: + + + + Other +
+ + + + + +
+ + Hair: + + + + Brown +
+ + + + + +
+ + Eyes: + + + + Blue +
+ + + + + +
+ + Weight: + + + + 45 kilos +
+ + + + + +
+ + Height: + + + + 165 centimeters +
+ + + + + +
+ + Age: + + + + 34 +
+ + + + + +
+ + City: + + + + Mountains +
+ + + + + + + + + + + +
+ + Sexual Preference: + + + + Bisexual +
+ + + + + +
+ + Smoke: + + + + Non Smoker +
+ + + + + +
+ + Drink: + + + + Non Drinker +
+ + + + + +
+ + Drugs: + + + + Never +
+ + + + + + + + +
+ + Occupation/Major: + + + + Guide +
+ + + + + + + + +
+ + Favorite Food: + + + + Chocolate +
+ + + + + +
+ + Pets: + + + + I dont like pets +
+ + + + + +
+ + Automobile: + + + + Ford +
+ + + + + +
+ + About Me: + + + + DMCA.com Protection Statuswebsite counter +
+
+
BlueAngelLove
+
+ CONTACT ME + +
+
Angel
+
+
+ I Want To Be Seduced +
+
+
+ I Love Flirt +
+
+
+ I Want Be Part Of Your life +
+
+
+ I Love Dancing +
+
+
+ I Love Erotic Chats +
+
+
+ I am Funny +
+
+
+ I Enjoy C2C +
+
+
+ I Love Sex and Feel u +
+
+
+
+
+
June Month Contestst-Top 3 tippers Get A gift mailed,videos,pictures and will my right hand full month and room helpers as well (be my men for a month or who knows...maybe forever) *** +Love Ya Angels*** We are currently ranked #2200 overall
+

Get Listed on My Wall of Fame

+
+
+ +

ElmosEgo 6570 Tks

+

Rw2lite 4800 Tks

+

Toastboi 2093 Tks

+

Acoolahole 1850 Tks

+

Gonodog 1299 Tks

+

Pumpy_G 800 Tks

+

Fowser 690 Tks

+

Aquanautic 600 Tks

+

Daveonthelake 535 Tks

+

Wildpervert2 500 Tks

+

Cloud10101 350 Tks

+

Branson102 337 Tks

+

TheCopperhead 329 Tks

+

Mouche99 250 Tks

+

The88drummer 233 Tks

+

Stringtrees86 199 Tks

+

Blazegordon 183 Tks

+

Waiting_4 183 Tks

+

Sam_mie 170 Tks

+

UtterTripe 150 Tks

+

Darth_penguin 150 Tks

+

Playfullpurv 120 Tks

+

Jordnsprings 103 Tks

+

Travelinlover 100 Tks

+

Da884 100 Tks

+ +
+ cory1 +
+
May Contest winners - Each month Top 3 tippers Get A gift mailed, videos and pictures - Love Ya Angels
+

Get Listed on My Wall of Fame

+
+
+

Rw2lite

+

ElmosEgo

+

TJuonesWoah

+ +
+ cory1 +
+
Menu Per Day
+

LOVE YA ANGELS

+
+
+

Monday - Outfits Strip

+

Tusday - Raffle

+

Wensday - Gamblers Night

+

Thusday - Orgasmic Vibra or Dildos

+

Friday - Wheel/Treat or Trick

+

Saturday - Phrase

+

Sunday - Keno and Boyfriend choice

+ + + +
+
You have to tip to get listed above so do your best to get on my exclusive Top Tippers List
+
+
+ Whats-App-Image-2019-01-09-at-10-35-17 + 45280406-1564895203655742-4887638015087738880-n + best + Whats-App-Image-2019-01-09-at-10-35-16 + + + + + + + + + + + + + + + + +
+
+
+
+ +Whats-App-Image-2019-05-12-at-05-55-35-1lovense-level
+
+
+
+
+camgirl xxx amateur sex sexy
+
+
+
+
+39741863-284302529029606-7659956026455621632-n +
+Let's Fun Laugh Live
I am Jullia from Transylvania and is a pleasure to have u around Enjoy me and my room

BlueAngelLove
I am good, but not an angel. I do sin, but I am not the devil. I am just a girl in a big world trying to find someone to love and be loved

+20171114-113848 +
~~~Live~Laugh~Love~~~Flag Counter +
+
+ + + + + +
+ + Tags: + + + + natural, blue eyes, toys, funny, oil, shower, fetish, costume, sex, natural, masturbation, finger, dp, anal, girl next door, romantic, naughty, pervert, open mind, play roles, horny, playful, smiley, lover, sweet, sexy, beautiful, hot, shaved, friendly, pussy, skype +
+ + + +
+ +
+ +
+ Friends +
+ +
+ + Average Rating: + + + + + +
+ +
+ + Rate BlueAngelLove: + + + + +
+ +
+ + Admirers: +
+
+ + (admire) +
+ +
+ + + +
+ + Favorite Models: + + + BlueAngelLove + +
+
+
+
+ +
+
+
+
+
+ +
+ Password Protected Galleries +
+ + + +
+
+ +
+ +
+
+
+
+ +
+ Photo Galleries +
+ + + +
+
+ +
+ +
+
+
+
+ +
+ My Schedule +
+
+ + Sunday + + + + I'm + Always + online from + 3:30 am + until + 7:00 am + +
+
+ + Monday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+
+ + Tuesday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+
+ + Wednesday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+
+ + Thursday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+
+ + Friday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+
+ + Saturday + + + + I'm + Always + online from + 3:30 pm + until + 7:00 am + +
+ +
+
+ +
+
+
+
+
+ +
+ Interests & Hobbies +
+ + + +
+ + Meaning of Life: + + + + Meaning of Life .To Love and Be Loved and keep what i have and who i have in my life right now +
+ + + + + +
+ + Five Things I Can't Live Without: + + + + -family +-phone +-sex +-love +-money +
+ + + + + +
+ + Favorite Books: + + + + My fav. book was Count of Monte Cristo +
+ + + + + +
+ + What I Like To Do For Fun: + + + + In my free time I dance, play games , go out and travel +
+ + + + + +
+ + Favorite Songs: + + + +
+
+ + + + + +
+ + Favorite Movies: + + + + +
+ + + + + + + + + + + +
+ + Hobbies: + + + + My Amazon Wishlistuk +
+ + + + + +
+ + Talents: + + + + i love to Dance , Travel and Cook +
+ + + + + +
+ + Perfect Mate: + + + + Perfect mate is Magic Mike +
+ + + + + +
+ + Perfect Date: + + + + Perfect Date .You and Me , romatic dinner and wild sex +
+ + + + + +
+ + Turn Ons/Offs: + + + + I hate Liers and Rude Peoples +
+ + + + + +
+ + Best Reason to Get to Know Me: + + + + My dear men, please dont put a label on medont make me a category before you get to know me! +
+ + + +
+
+ +
+ +
+ + + + +
+
+

Send MFC Mail to BlueAngelLove

+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs index a49ba9549..bc48341ca 100644 --- a/test/web/rich_media/parser_test.exs +++ b/test/web/rich_media/parser_test.exs @@ -9,6 +9,12 @@ defmodule Pleroma.Web.RichMedia.ParserTest do } -> %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")} + %{ + method: :get, + url: "http://example.com/non-ogp" + } -> + %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/non_ogp_embed.html")} + %{ method: :get, url: "http://example.com/ogp-missing-title" @@ -47,6 +53,11 @@ defmodule Pleroma.Web.RichMedia.ParserTest do assert {:error, _} = Pleroma.Web.RichMedia.Parser.parse("http://example.com/empty") end + test "doesn't just add a title" do + assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/non-ogp") == + {:error, "Found metadata was invalid or incomplete: %{}"} + end + test "parses ogp" do assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp") == {:ok,