Merge pull request #38 from jonschoning/non-http-url-schemes

add setting ALLOW_NON_HTTP_URL_SCHEMES
This commit is contained in:
Jon Schoning 2022-04-26 21:11:45 -05:00 committed by GitHub
commit 368c5db510
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 8 deletions

View file

@ -1,3 +1,6 @@
__v0.0.13__
add setting ALLOW_NON_HTTP_URL_SCHEMES (default false)
__v0.0.12__ __v0.0.12__
update to ghc9 update to ghc9

View file

@ -43,3 +43,5 @@ archive-socks-proxy-port: "_env:ARCHIVE_SOCKS_PROXY_PORT"
source-code-uri: "_env:SOURCE_CODE_URI:https://github.com/jonschoning/espial" source-code-uri: "_env:SOURCE_CODE_URI:https://github.com/jonschoning/espial"
ssl-only: "_env:SSL_ONLY" # false ssl-only: "_env:SSL_ONLY" # false
allow-non-http-url-schemes: "_env:ALLOW_NON_HTTP_URL_SCHEMES:false"

View file

@ -13,8 +13,10 @@ services:
environment: environment:
- IP_FROM_HEADER=true - IP_FROM_HEADER=true
- SQLITE_DATABASE=/app/data/espial.sqlite3 - SQLITE_DATABASE=/app/data/espial.sqlite3
# - DETAILED_LOGGING=true # - SSL_ONLY=false
# - SHOULD_LOG_ALL=true # - DETAILED_LOGGING=false
# - SHOULD_LOG_ALL=false
# - ARCHIVE_SOCKS_PROXY_HOST=localhost # - ARCHIVE_SOCKS_PROXY_HOST=localhost
# - ARCHIVE_SOCKS_PROXY_PORT=8888 # - ARCHIVE_SOCKS_PROXY_PORT=8888
# - SOURCE_CODE_URI=https://github.com/jonschoning/espial # - SOURCE_CODE_URI=https://github.com/jonschoning/espial
# - ALLOW_NON_HTTP_URL_SCHEMES=false

View file

@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: espial name: espial
version: 0.0.12 version: 0.0.13
synopsis: Espial is an open-source, web-based bookmarking server. synopsis: Espial is an open-source, web-based bookmarking server.
description: . description: .
Espial is an open-source, web-based bookmarking server. Espial is an open-source, web-based bookmarking server.

View file

@ -1,6 +1,6 @@
name: espial name: espial
synopsis: Espial is an open-source, web-based bookmarking server. synopsis: Espial is an open-source, web-based bookmarking server.
version: "0.0.12" version: "0.0.13"
description: ! ' description: ! '
Espial is an open-source, web-based bookmarking server. Espial is an open-source, web-based bookmarking server.

View file

@ -68,16 +68,17 @@ postAddR = do
_handleFormSuccess :: BookmarkForm -> Handler (UpsertResult (Key Bookmark)) _handleFormSuccess :: BookmarkForm -> Handler (UpsertResult (Key Bookmark))
_handleFormSuccess bookmarkForm = do _handleFormSuccess bookmarkForm = do
(userId, user) <- requireAuthPair (userId, user) <- requireAuthPair
case (parseRequest . unpack . _url) bookmarkForm of appSettings <- appSettings <$> getYesod
Nothing -> pure $ Failed "Invalid URL" case (appAllowNonHttpUrlSchemes appSettings, (parseRequest . unpack . _url) bookmarkForm) of
Just _ -> do (False, Nothing) -> pure $ Failed "Invalid URL"
(_, _) -> do
let mkbid = BookmarkKey <$> _bid bookmarkForm let mkbid = BookmarkKey <$> _bid bookmarkForm
tags = maybe [] (nub . words . T.replace "," " ") (_tags bookmarkForm) tags = maybe [] (nub . words . T.replace "," " ") (_tags bookmarkForm)
bm <- liftIO $ _toBookmark userId bookmarkForm bm <- liftIO $ _toBookmark userId bookmarkForm
res <- runDB (upsertBookmark userId mkbid bm tags) res <- runDB (upsertBookmark userId mkbid bm tags)
forM_ (maybeUpsertResult res) $ \kbid -> forM_ (maybeUpsertResult res) $ \kbid ->
whenM (shouldArchiveBookmark user kbid) $ whenM (shouldArchiveBookmark user kbid) $
void $ async (archiveBookmarkUrl kbid (unpack (bookmarkHref bm))) void $ async (archiveBookmarkUrl kbid (unpack (bookmarkHref bm)))
pure res pure res
postLookupTitleR :: Handler () postLookupTitleR :: Handler ()

View file

@ -66,6 +66,8 @@ data AppSettings = AppSettings
-- ^ Uri to app source code -- ^ Uri to app source code
, appSSLOnly :: Bool , appSSLOnly :: Bool
, appAllowNonHttpUrlSchemes :: Bool
} }
instance FromJSON AppSettings where instance FromJSON AppSettings where
@ -102,6 +104,8 @@ instance FromJSON AppSettings where
appSSLOnly <- fromMaybe False <$> o .:? "ssl-only" appSSLOnly <- fromMaybe False <$> o .:? "ssl-only"
appAllowNonHttpUrlSchemes <- fromMaybe False <$> o .:? "allow-non-http-url-schemes"
return AppSettings {..} return AppSettings {..}
-- | Settings for 'widgetFile', such as which template languages to support and -- | Settings for 'widgetFile', such as which template languages to support and