diff --git a/Modules/Parser/Sources/Parser/FeedParser/Feeds/XML/AtomParser.swift b/Modules/Parser/Sources/Parser/FeedParser/Feeds/XML/AtomParser.swift index d828e9e5e..152f76704 100644 --- a/Modules/Parser/Sources/Parser/FeedParser/Feeds/XML/AtomParser.swift +++ b/Modules/Parser/Sources/Parser/FeedParser/Feeds/XML/AtomParser.swift @@ -25,6 +25,7 @@ final class AtomParser { attributesStack.last } + private var xmlBaseURL: URL? private var parsingXHTML = false private var xhtmlString: String? @@ -90,6 +91,7 @@ private extension AtomParser { static let type = "type" static let length = "length" static let xmlLang = "xml:lang" + static let xmlBase = "xml:base" } func currentString(_ saxParser: SAXParser) -> String? { @@ -139,13 +141,23 @@ private extension AtomParser { } } - func addFeedLanguage() { + func addFeedAttributes() { - guard feed.language == nil, let currentAttributes else { + guard let currentAttributes else { return } - feed.language = currentAttributes[XMLString.xmlLang] + if feed.language == nil { + feed.language = currentAttributes[XMLString.xmlLang] + } + + if xmlBaseURL == nil { + if let xmlBase = currentAttributes[XMLString.xmlBase] { + if let baseURL = URL(string: xmlBase) { + xmlBaseURL = baseURL + } + } + } } func addArticle() { @@ -225,7 +237,8 @@ private extension AtomParser { guard let urlString = attributes[XMLString.href], !urlString.isEmpty else { return } - + let resolvedURLString = linkResolvedAgainstXMLBase(urlString) + var rel = attributes[XMLString.rel] if rel?.isEmpty ?? true { rel = XMLString.alternate @@ -233,21 +246,33 @@ private extension AtomParser { if rel == XMLString.related { if article.link == nil { - article.link = urlString + article.link = resolvedURLString } } else if rel == XMLString.alternate { if article.permalink == nil { - article.permalink = urlString + article.permalink = resolvedURLString } } else if rel == XMLString.enclosure { - if let enclosure = enclosure(urlString, attributes) { + if let enclosure = enclosure(resolvedURLString, attributes) { article.addEnclosure(enclosure) } } } + func linkResolvedAgainstXMLBase(_ urlString: String) -> String { + + guard let xmlBaseURL else { + return urlString + } + + if let resolvedURL = URL(string: urlString, relativeTo: xmlBaseURL) { + return resolvedURL.absoluteString + } + return urlString + } + func enclosure(_ urlString: String, _ attributes: StringDictionary) -> RSSEnclosure? { let enclosure = RSSEnclosure(url: urlString) @@ -351,7 +376,7 @@ extension AtomParser: SAXParserDelegate { } if SAXEqualTags(localName, XMLName.feed) { - addFeedLanguage() + addFeedAttributes() } saxParser.beginStoringCharacters() diff --git a/Modules/Parser/Tests/ParserTests/AtomParserTests.swift b/Modules/Parser/Tests/ParserTests/AtomParserTests.swift index 39dd3b72e..6ff62f927 100644 --- a/Modules/Parser/Tests/ParserTests/AtomParserTests.swift +++ b/Modules/Parser/Tests/ParserTests/AtomParserTests.swift @@ -109,4 +109,22 @@ final class AtomParserTests: XCTestCase { XCTAssertNotEqual(article.title, "Default Title") } } + + func testLinkElementsWithRelativeURLs() { + + // This feed has elements that look like this… + // + // …and it also has, in the feed declaration… + // xml:base="https://blog.adobe.com" + // …and so the values should be parsed as (for example): + // https://blog.adobe.com/en/publish/2022/07/01/great-moments-in-document-history-reimagining-the-declaration-of-independence-as-pdf + // Issue: https://github.com/Ranchero-Software/NetNewsWire/issues/3662 + + let d = parserData("adobe", "atom", "https://blog.adobe.com/feed.xml") + let parsedFeed = try! FeedParser.parse(d)! + + for article in parsedFeed.items { + XCTAssertTrue(article.url!.hasPrefix("https://blog.adobe.com/en/publish/20")) + } + } } diff --git a/Modules/Parser/Tests/ParserTests/Resources/adobe.atom b/Modules/Parser/Tests/ParserTests/Resources/adobe.atom new file mode 100644 index 000000000..3bdc327f8 --- /dev/null +++ b/Modules/Parser/Tests/ParserTests/Resources/adobe.atom @@ -0,0 +1 @@ +Adobe Blog2022-07-03T19:54:31.492ZAdobehttps://blog.adobe.com/Great moments in document history: Reimagining the Declaration of Independence as a PDFAdobe Acrobat Teamhttps://blog.adobe.com/en/publish/2022/07/01/great-moments-in-document-history-reimagining-the-declaration-of-independence-as-pdf2022-07-01T00:00:00.000ZBy the time the Declaration of Independence was ratified, nearly 100 manual alterations had been made to the handwritten document. If only they had PDF.Sakshi Sachdev on being fueled by challenges in the technical realmAdobe Life Teamhttps://blog.adobe.com/en/publish/2022/06/30/sakshi-sachdev-fuelled-by-challenges-in-tech2022-06-30T00:00:00.000ZFrom individual contributor to senior director of engineering, Sakshi Sachdev’s journey has been one of creating, ideating, and solving. Find out what motivates her to work alongside her Adobe team.Using certified digital signatures on documents to increase trust in online informationSteven Gottwalshttps://blog.adobe.com/en/publish/2022/06/30/using-certified-digital-signatures-on-documents-to-increase-trust-in-online-information2022-06-30T00:00:00.000ZIn a world where people increasingly question the validity of the information they consume online, readers need to know that the documents they download come from a trusted source.Fresh new foundries and fonts from the Americas, and Hidden Treasures revisitedYves Petershttps://blog.adobe.com/en/publish/2022/06/30/fresh-new-foundries-fonts-from-americas-hidden-treasures-revisited2022-06-30T00:00:00.000ZThree new foundries add fonts to Adobe Fonts library included with Creative Cloud subscriptionAdvocating for the planet and representation of the LGBTQIA+ community with Adobe Lightroom Ambassador Julia NimkeRani Manihttps://blog.adobe.com/en/publish/2022/06/29/advocating-for-planet-representation-lgbtqia-community-with-adobe-lightroom-ambassador-julia-nimke2022-06-29T00:00:00.000ZAdobe Lightroom Ambassador and commercial photographer Julia Nimke advocates for the planet and representation of the LGBTQIA+ communityDo customers care about your brand’s integrity?Trustpilothttps://blog.adobe.com/en/publish/2022/06/28/do-customers-care-about-your-brands-integrity2022-06-28T00:00:00.000ZMany brands are getting vocal about ethical purpose and honesty. But does brand integrity really influence the behavior of consumers?How to get started in user experience designTorin Edwardshttps://blog.adobe.com/en/publish/2022/06/27/how-to-get-started-in-ux-design2022-06-27T00:00:00.000ZUser experience design is essential – and everywhere. Senior experience designer Torin Edwards breaks down the fundamentals of UX, important resources, and how to get started and build your portfolio - the right way.How to capture aerial real estate photographyMarc Weisberghttps://blog.adobe.com/en/publish/2022/06/27/aerial-photography-real-estate-photographer-guide2022-06-27T00:00:00.000ZWhether you’re shooting large commercial complexes, or residential properties, mastering aerial photography is paramount for capturing the perfect shot.Behold the bold — announcing the 2022 Adobe Experience Maker Awards winnersEric Hallhttps://blog.adobe.com/en/publish/2022/06/24/behold-the-bold-announcing-the-winners-of-the-2022-adobe-experience-maker-awards2022-06-24T00:00:00.000ZThe Adobe Experience Maker Awards recognize and celebrate innovative, bold, and impactful achievements as customer experience drives digital transformation across industries and around the world.Letting machine learning choose the right font for everyoneZoya Bylinskiihttps://blog.adobe.com/en/publish/2022/06/23/letting-machine-learning-choose-the-right-font-for-everyone2022-06-23T00:00:00.000ZPersonalized Font Recommendations: Combining ML and Typographic Guidelines to Optimize ReadabilityNucleus Network streamlines clinical trial management with Adobe Acrobat SignAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/22/nucleus-network-streamlines-clinical-trial-management-with-adobe-acrobat-sign2022-06-22T00:00:00.000ZNucleus Network uses the Bio Pharma settings in Adobe Acrobat Sign to comply with 21 CFR Part 11 regulations for digital signatures on clinical trial paperwork.Bringing teams together for the digital transformation of healthcare: the CVS Health Creative JamOliver Lindberghttps://blog.adobe.com/en/publish/2022/06/22/cvs-creative-jam-digitally-transforming-healthcare-xd2022-06-22T00:00:00.000ZCVS Health’s Creative Jam with Adobe is reshaping the way they approach collaboration and streamlining workflows to help digitally transform healthcare.No selfies here: Chinelle Rojas shares her tips for powerful self-portraitsChinelle Rojashttps://blog.adobe.com/en/publish/2022/06/21/no-selfies-here-chinelle-rojas-shares-her-tips-for-powerful-self-portraits2022-06-21T00:00:00.000ZReally good self-portraits take a lot of patience. Chinelle Rojas, the selfie queen, shares some of her most effective tips for creating powerful shots.How Adobe is helping student athletes at HBCUs and HSIs discover a career in technologyVaishali Sabhahithttps://blog.adobe.com/en/publish/2022/06/21/how-adobe-is-helping-student-athletes-at-hbcus-and-hsis-discover-a-career-in-technology2022-06-21T00:00:00.000ZAs Adobe kick off its internship season this year, we're spotlighting a new initiative that will provide support and career opportunities to student athletes at HBCUs and HSIs in the U.S.Meet the 2022 Women at Sundance | Adobe FellowsAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/21/announcing-2022-women-at-sundance-adobe-fellows2022-06-21T00:00:00.000ZMeet the 2022 Women at Sundance | Adobe Fellows. At Adobe, we believe that creativity lives within everyone, and we are committed to supporting, elevating and amplifying underrepresented creators, so the world can see, learn and benefit from more perspectives.Adobe Lightroom Ambassador Kane Andrade on finding beauty in pain through photographyRani Manihttps://blog.adobe.com/en/publish/2022/06/20/adobe-lightroom-ambassador-kane-andrade-on-finding-beauty-in-pain-through-photography2022-06-20T00:00:00.000ZAdobe Lightroom Ambassador and transgender photographer Kane Andrade finds beauty in pain and a community through his creativityCelebrating the flavors of JuneteenthIrene Malatestahttps://blog.adobe.com/en/publish/2022/06/20/celebrating-the-flavors-of-juneteenth2022-06-20T00:00:00.000ZAdobe’s purpose is to enable creativity for all, and the Juneteenth commemoration opens up a wide range of opportunities for individuals to authentically depict their lives and experiences. We’re partnering with Adobe Stock artist O Koren, a nonbinary “photo ethnographer” whose work most often focuses on Black contributions to American foodways and popular culture.Celebrating creatives, mentors and mentees with #WomenCreateAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/16/celebrating-creatives-mentors-and-mentees-with-womencreate2022-06-16T00:00:00.000ZAdobe’s creative community in Asia Pacific celebrate #WomenCreate through ‘Womentorship’Honoring Juneteenth and Windrush DayKenneth Imohttps://blog.adobe.com/en/publish/2022/06/16/honoring-juneteenth-windrush-day2022-06-16T00:00:00.000ZNew Global Head of Diversity, Kenneth Imo, shares his reflections on the significance of Juneteenth and Windrush Day and the importance behind honoring them.Kenneth “Professor” Hines teaches and inspires through photographyRani Manihttps://blog.adobe.com/en/publish/2022/06/16/kenneth-professor-hines-teaches-and-inspires-through-photography2022-06-16T00:00:00.000ZBlack photographer and Adobe Lightroom “Professor” Kenneth Hines, Jr. teaches, inspires, and aims to positively impact society with his images.Talking with tiger sharks: Patrick Masse’s images bring us into conversation with the animal worldMalcolm Thorndike Nicholsonhttps://blog.adobe.com/en/publish/2022/06/16/talking-with-tiger-sharks-patrick-masses-images-bring-us-into-conversation-with-animal-world2022-06-16T00:00:00.000ZCreating simple, beautiful, and evocative images of 60,000-pound mammals like Humpback whales requires a photographer like Patrick Masse. He spoke to us about how he creates his work.Terrell Wade shines a bright, hilarious light on working lifeAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/16/terrell-wade-shines-a-bright-hilarious-light-on-working-life2022-06-16T00:00:00.000ZSocial media comedy star Terrell Wade aka ‘The Wade Empire’ on content creation, his funny focus on office life, and why he uses Adobe Acrobat to manage his documents.Adobe Acrobat and Adrienne Bailon-Houghton give entrepreneurs the title they deserve: Chief Home OfficerAdobe Acrobat Teamhttps://blog.adobe.com/en/publish/2022/06/15/adobe-acrobat-adrienne-bailon-houghton-give-entrepreneurs-title-they-deserve-chief-home-officer2022-06-15T00:00:00.000ZAdobe Acrobat surveyed 750 small businesses, microentrepreneurs, and big business employees, and spoke with celeb Adrienne Bailon-Houghton to understand more about their day-to-day work life.Kasha Stewart’s unconventional path from film to product managementAdobe Life Teamhttps://blog.adobe.com/en/publish/2022/06/15/kasha-stewart-path-film-product-management2022-06-15T00:00:00.000ZKasha Stewart, director of growth and engagement for Adobe Express, moved from video production into the product world by asking a lot of questions.Where’s anywhere? Top 20 most popular cities for remote workersDocument Cloud Teamhttps://blog.adobe.com/en/publish/2022/06/15/wheres-anywhere-top-20-most-popular-cities-for-remote-workers2022-06-15T00:00:00.000ZRemote work might be here to stay. Here's the top cities for remote workers.June 2022 photography releasesBenjamin Wardehttps://blog.adobe.com/en/publish/2022/06/14/june-2022-photography-releases2022-06-14T00:00:00.000ZThe Adobe photography team is excited to announce the latest updates to Lightroom and Lightroom Classic. These releases begin rolling out today and will be available to everyone by the end of the week.Spotlight on the editors of Tribeca Film Festival 2022Meagan Keanehttps://blog.adobe.com/en/publish/2022/06/14/spotlight-on-editors-of-tribeca-film-festival-20222022-06-14T00:00:00.000ZAdobe is celebrating filmmakers at this year’s Tribeca Film Festival in New York City from June 8-19. Learn about the films and filmmakers taking Tribeca by storm this year!Adobe Analytics: Domestic flight prices increased 47 percent since January — demand remains above pre-pandemic levelsAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/14/adobe-analytics-domestic-flight-prices-increased-47-percent-since-january-demand-remains-above-pre-pandemic-levels2022-06-14T00:00:00.000ZAdobe provides the most comprehensive report of its kind, measuring direct consumer transactions from 6 of the top 10 U.S. airlines and over 150 billion web visits.Celebrating the Legacy of an Icon of Sound + Vision: Adobe’s new David Bowie-inspired digital tools invite fans to create their own unique personasSimon Morrishttps://blog.adobe.com/en/publish/2022/06/14/celebrating-the-legacy-of-an-icon-of-sound-vision-adobe-new-david-bowie-inspired-digital-tools-invite-fans-to-create-their-own-unique-personas2022-06-14T00:00:00.000ZAdobe’s new David Bowie-inspired digital tools invite fans to create their own unique personasBlending flavors: Simi Jois on culinary photography and cultural mergeSarah Rose Sharphttps://blog.adobe.com/en/publish/2022/06/10/blending-flavors-simi-jois-on-culinary-photography-cultural-merge2022-06-10T00:00:00.000ZAdobe Stock Artist Development Fund winner Simi Jois is a culinary photographer and stylist. She brings real passion to her profession, her cooking and pictures to connect to heritage, family, and community.Crooked Media and Adobe partner to make podcasts more accessibleMeagan Keanehttps://blog.adobe.com/en/publish/2022/06/08/crooked-media-and-adobe-partner-to-make-podcasts-more-accessible2022-06-08T00:00:00.000ZVideo and podcasting are both skyrocketing in popularity and it’s crucial to turn around content on tight deadlines. Crooked Media now makes its award-winning content accessible through captioning with Adobe Creative Cloud.Every Color, Every Shade, EverywhereShannon Brownhttps://blog.adobe.com/en/publish/2022/06/08/every-color-every-shade-everywhere2022-06-08T00:00:00.000ZEvery Color, Every Shade, Everywhere is inclusive of all of us, and reflects Adobe’s commitment to supporting the LGBTQIA+ community.How to patent your ideaKristine Hamletthttps://blog.adobe.com/en/publish/2022/06/08/how-to-patent-your-idea2022-06-08T00:00:00.000ZLearn the ins and outs of the entire patent application process from Adobe researchers who know it best – with 100 patents each to their names.Celebrating the ocean through creativity and educationAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/08/celebrating-ocean-through-creativity-education2022-06-08T00:00:00.000ZAs part of an ongoing commitment to a more sustainable future, Adobe is partnering with The Ocean Agency (TOA) and The Florida Aquarium (TFA) to launch its first-ever digital Ocean Decade Exhibition, just in time for World Ocean Day.How Averie Bishop, a law student turned viral content creator, finds perfection in the imperfectAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/07/how-averie-bishop-a-law-student-turned-viral-content-creator-finds-perfection-in-the-imperfect2022-06-07T00:00:00.000ZGet a free PDF Kit from Averie Bishop to help prep for any interview, from jobs to pageants and beyond.Women creating impact in film – and beyondKristine Hamletthttps://blog.adobe.com/en/publish/2022/06/07/women-creating-impact-in-film-beyond2022-06-07T00:00:00.000ZGet to know two filmmakers — Emilana Ammirata and Naëmi Buchtemann — both awarded a year of mentorship by The Sundance Ignite x Adobe short film challenge. Learn what they are doing to advance women in film, beyond their own careers.Behold the bold — announcing the 2022 Adobe Experience Maker Awards FinalistsEric Hallhttps://blog.adobe.com/en/publish/2022/06/07/behold-the-bold-announcing-2022-adobe-experience-maker-awards-finalists2022-06-07T00:00:00.000ZThe Adobe Experience Maker Awards recognize and celebrate innovative, bold, and impactful achievements as customer experience drives digital transformation across industries and around the world.Everything is <3 in life and Acrobat, according to Frederic ChenAdobe Acrobat Teamhttps://blog.adobe.com/en/publish/2022/06/06/everything-is-3-in-life-and-acrobat-according-to-frederic-chen2022-06-06T00:00:00.000ZLearn about self-care, creativity, and using Acrobat for school from this YouTube influencer.Adobe reaches public sector milestone with FedRAMP Moderate authorization for Adobe Acrobat Sign for GovernmentHeather Whitlockhttps://blog.adobe.com/en/publish/2022/06/06/adobe-reaches-public-sector-milestone-with-fedramp-moderate-authorization-for-adobe-acrobat-sign-for-government2022-06-06T00:00:00.000ZThe newly acquired FedRAMP Moderate level of authorization allows Adobe Acrobat Sign for Government to immediately address existing public sector workforce pain points and enables government growth toward long-term IT modernization.Jacob Leon on life in Adobe sales, the business skills of wrestling, and taking a chance on the other side of the worldAdobe Life Teamhttps://blog.adobe.com/en/publish/2022/06/06/jacob-leon-life-sales-wrestling-taking-chances2022-06-06T00:00:00.000ZHear from Jacob as we talk to him about life on the Adobe Sign team, the big move, and how his background as a college wrestler helped set him up for success.How Adobe Sneaks go from “onstage” into appKristine Hamletthttps://blog.adobe.com/en/publish/2022/06/01/adobe-sneaks-on-stage-to-app2022-06-01T00:00:00.000ZTwice a year Adobe engineers take the stage at Adobe MAX and Adobe Summit to show off early tech innovation they’re developing. Here’s how – and why – they do it.How Adobe Acrobat Sign helps Acepodia comply with FDA regulationsAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/06/01/how-adobe-acrobat-sign-helps-acepodia-comply-with-fda-regulations2022-06-01T00:00:00.000ZAcepodia digitized agreements with contract research organization using Adobe Acrobat Sign.Printed colors will soon be more vivid and accurateMark Lewieckihttps://blog.adobe.com/en/publish/2022/05/31/printed-colors-will-soon-be-more-vivid-and-accurate2022-05-31T00:00:00.000ZAdobe PDF Print Engine 6 delivers the latest color science and imaging technology to help brighten our world with more vivid and accurate colors.Different ways and places to find creative inspoKristine Hamletthttps://blog.adobe.com/en/publish/2022/05/27/national-creativity-day2022-05-27T00:00:00.000ZTo celebrate National Creativity Day we asked our community of creators just what creative self-expression looks like for them, how creativity shows up in their daily lives and where they get their best ideas.Hitting the road with singer-songwriter Olivia RodrigoMeagan Keanehttps://blog.adobe.com/en/publish/2022/05/26/hitting-the-road-with-singer-songwriter-olivia-rodrigo2022-05-26T00:00:00.000ZRead how the editors put together OLIVIA RODRIGO: driving home 2 u (a SOUR film), which follows the Grammy® winning artist as she takes a familiar road trip from Salt Lake City to LA. The film combines live arrangements of her songs, intimate interviews, and never-before-seen footage.How State of Escape is breaking the bias in the fashion industryAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/05/26/how-state-of-escape-is-breaking-the-bias-in-the-fashion-industry2022-05-26T00:00:00.000ZInvesting in opportunities for and the success of women is core to fashion brand State of Escape’s ethos and has driven its rapid rise in the fashion industry.The long road home to self-expression with illustrator Carina LindmeierSarah Rose Sharphttps://blog.adobe.com/en/publish/2022/05/25/the-long-road-home-to-self-expression-with-illustrator-carina-lindmeier2022-05-25T00:00:00.000ZEven as a child, Carina Lindmeier knew that art was her calling, but her first foray into a creative profession found her on the administrative side of advertising.Adobe and Microsoft announce new, deeper integrations to turbocharge the modern workplaceAdobe Communications Teamhttps://blog.adobe.com/en/publish/2022/05/24/adobe-microsoft-announce-new-deeper-integrations-to-turbocharge-modern-workplace2022-05-24T00:00:00.000ZToday at Microsoft Build, Adobe announced its latest milestone in the partnership with Microsoft to improve how work gets done today. Through new advances in business processes and intelligent automation, we continue to give our joint customers the most modern work experience, centered on technology that enhances teamwork, collaboration, and efficiencies.Turning challenge into opportunity: Discussing net zero strategies at Mornings with AdobeAdobe Communicationshttps://blog.adobe.com/en/publish/2022/05/20/turning-challenge-into-opportunity-discussing-net-zero-strategies-at-mornings-with-adobe2022-05-20T00:00:00.000ZTo commemorate the 52nd Earth Day, Adobe brought a panel of sustainability leaders together for the April edition of its Mornings with Adobe event, held at the Barbican Conservatory – one of the UK’s most proactively sustainable venues – to discuss the successes, challenges, and learnings from the net zero journey so far. \ No newline at end of file