From 2323af373658887e7e4d93ee38d92c9ea3cd516c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 11 Mar 2023 13:52:41 -0400 Subject: [PATCH] importfeed: Display feed title When importing a bunch of feeds, this makes it more clear what it's working on. Also, I sometimes want to delete a particular feed from a list of feeds but don't know which url belongs to the feed, and this solves that. Control characters are filtered out just to protect against some feed putting escape character stuff in the feed, which could be a security problem. (Control characters also get filtered out of importfeed filenames.) Sponsored-by: Luke Shumaker on Patreon --- CHANGELOG | 1 + Command/ImportFeed.hs | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3d4b8e181e..e5202600f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ git-annex (10.20230228) UNRELEASED; urgency=medium * Added arm64 build for ancient kernels, needed to support Android phones whose kernels are too old to support kernels used by the current arm64 build. + * importfeed: Display feed title. -- Joey Hess Mon, 27 Feb 2023 12:31:14 -0400 diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index a2a6284eb3..1a874408a7 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -16,6 +16,7 @@ import Text.Feed.Query import Text.Feed.Types import qualified Data.Set as S import qualified Data.Map as M +import Data.Char import Data.Time.Clock import Data.Time.Format import Data.Time.Calendar @@ -93,15 +94,22 @@ getFeed addunlockedmatcher opts cache url = do -- ourselves because it goes out of its way to handle encodings. go tmpf = liftIO (parseFeedFromFile' tmpf) >>= \case Nothing -> debugfeedcontent tmpf "parsing the feed failed" - Just f -> case findDownloads url f of - [] -> debugfeedcontent tmpf "bad feed content; no enclosures to download" - l -> do - showEndOk - ifM (and <$> mapM (performDownload addunlockedmatcher opts cache) l) - ( clearFeedProblem url - , void $ feedProblem url - "problem downloading some item(s) from feed" - ) + Just f -> do + case map sanitizetitle $ decodeBS $ fromFeedText $ getFeedTitle f of + "" -> noop + t -> showNote ('"' : t ++ "\"") + case findDownloads url f of + [] -> debugfeedcontent tmpf "bad feed content; no enclosures to download" + l -> do + showEndOk + ifM (and <$> mapM (performDownload addunlockedmatcher opts cache) l) + ( clearFeedProblem url + , void $ feedProblem url + "problem downloading some item(s) from feed" + ) + sanitizetitle c + | isControl c = '_' + | otherwise = c debugfeedcontent tmpf msg = do feedcontent <- liftIO $ readFile tmpf fastDebug "Command.ImportFeed" $ unlines