importfeed: Display feed title
authorJoey Hess <joeyh@joeyh.name>
Sat, 11 Mar 2023 17:52:41 +0000 (13:52 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sat, 11 Mar 2023 17:52:45 +0000 (13:52 -0400)
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
Command/ImportFeed.hs

index 3d4b8e181eb9d045e858a9e4f6c3da8d86577f5c..e5202600f838bb9e1bf8b21ae1621522a80d698e 100644 (file)
--- 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 <id@joeyh.name>  Mon, 27 Feb 2023 12:31:14 -0400
 
index a2a6284eb324c0e06abb25e247946b7d9780924c..1a874408a70cb030c71b92746dea4f7ae83d7daa 100644 (file)
@@ -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