chore(lpr): sanitze printjob names, remove unusable printAckFree route
This commit is contained in:
parent
a6b62674d2
commit
8a60cd8c02
1
routes
1
routes
@ -71,7 +71,6 @@
|
|||||||
/print PrintCenterR GET POST !system-printer
|
/print PrintCenterR GET POST !system-printer
|
||||||
/print/acknowledge/#Day/#Int/#Int PrintAckR GET POST !system-printer
|
/print/acknowledge/#Day/#Int/#Int PrintAckR GET POST !system-printer
|
||||||
/print/acknowledge/direct PrintAckDirectR POST !system-printer
|
/print/acknowledge/direct PrintAckDirectR POST !system-printer
|
||||||
/print/acknowledge/free/direct PrintAckFreeR POST !development
|
|
||||||
/print/send PrintSendR GET POST
|
/print/send PrintSendR GET POST
|
||||||
/print/download/#CryptoUUIDPrintJob PrintDownloadR GET !system-printer
|
/print/download/#CryptoUUIDPrintJob PrintDownloadR GET !system-printer
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,6 @@ breadcrumb PrintSendR = i18nCrumb MsgMenuPrintSend $ Just PrintCenter
|
|||||||
breadcrumb PrintDownloadR{} = i18nCrumb MsgMenuPrintDownload $ Just PrintCenterR
|
breadcrumb PrintDownloadR{} = i18nCrumb MsgMenuPrintDownload $ Just PrintCenterR
|
||||||
breadcrumb PrintAckR{} = i18nCrumb MsgMenuPrintSend $ Just PrintCenterR -- never displayed
|
breadcrumb PrintAckR{} = i18nCrumb MsgMenuPrintSend $ Just PrintCenterR -- never displayed
|
||||||
breadcrumb PrintAckDirectR{}= i18nCrumb MsgMenuPrintSend $ Just PrintCenterR -- never displayed
|
breadcrumb PrintAckDirectR{}= i18nCrumb MsgMenuPrintSend $ Just PrintCenterR -- never displayed
|
||||||
breadcrumb PrintAckFreeR{} = i18nCrumb MsgMenuPrintSend $ Just PrintCenterR -- never displayed
|
|
||||||
|
|
||||||
breadcrumb SchoolListR = i18nCrumb MsgMenuSchoolList $ Just AdminR
|
breadcrumb SchoolListR = i18nCrumb MsgMenuSchoolList $ Just AdminR
|
||||||
breadcrumb (SchoolR ssh sRoute) = case sRoute of
|
breadcrumb (SchoolR ssh sRoute) = case sRoute of
|
||||||
|
|||||||
@ -10,8 +10,7 @@ module Handler.PrintCenter
|
|||||||
, getPrintCenterR, postPrintCenterR
|
, getPrintCenterR, postPrintCenterR
|
||||||
, getPrintSendR , postPrintSendR
|
, getPrintSendR , postPrintSendR
|
||||||
, getPrintAckR , postPrintAckR
|
, getPrintAckR , postPrintAckR
|
||||||
, postPrintAckDirectR
|
, postPrintAckDirectR
|
||||||
, postPrintAckFreeR
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
@ -447,7 +446,3 @@ postPrintAckDirectR = do
|
|||||||
$logErrorS "APC" msg
|
$logErrorS "APC" msg
|
||||||
return (badRequest400, msg)
|
return (badRequest400, msg)
|
||||||
sendResponseStatus status msg -- must be outside of runDB; otherweise transaction is rolled back
|
sendResponseStatus status msg -- must be outside of runDB; otherweise transaction is rolled back
|
||||||
|
|
||||||
-- synonym, used during development to test with and without access control simultaneously
|
|
||||||
postPrintAckFreeR :: Handler Html
|
|
||||||
postPrintAckFreeR = postPrintAckDirectR
|
|
||||||
41
src/Utils.hs
41
src/Utils.hs
@ -23,6 +23,7 @@ import qualified Data.CaseInsensitive as CI
|
|||||||
|
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import qualified Data.ByteString.Char8 as CBS
|
import qualified Data.ByteString.Char8 as CBS
|
||||||
|
import qualified Data.Char as Char
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Data.Text.Encoding as Text
|
import qualified Data.Text.Encoding as Text
|
||||||
|
|
||||||
@ -298,6 +299,46 @@ citext2lower = Text.toLower . CI.original
|
|||||||
citext2string :: CI Text -> String
|
citext2string :: CI Text -> String
|
||||||
citext2string = Text.unpack . CI.original
|
citext2string = Text.unpack . CI.original
|
||||||
|
|
||||||
|
-- | Convert or remove all non-ascii characters, e.g. for filenames
|
||||||
|
text2asciiAlphaNum :: Text -> Text
|
||||||
|
text2asciiAlphaNum = Text.filter (\c -> Char.isAlphaNum c && Char.isAscii c)
|
||||||
|
. Text.replace "ä" "ae"
|
||||||
|
. Text.replace "Ä" "Ae"
|
||||||
|
. Text.replace "Æ" "ae"
|
||||||
|
. Text.replace "æ" "ae"
|
||||||
|
. Text.replace "Å" "Aa"
|
||||||
|
. Text.replace "å" "aa"
|
||||||
|
. Text.replace "â" "a"
|
||||||
|
. Text.replace "à" "a"
|
||||||
|
. Text.replace "á" "a"
|
||||||
|
. Text.replace "Ö" "Oe"
|
||||||
|
. Text.replace "ö" "oe"
|
||||||
|
. Text.replace "œ" "oe"
|
||||||
|
. Text.replace "Ø" "Oe"
|
||||||
|
. Text.replace "ø" "oe"
|
||||||
|
. Text.replace "ò" "o"
|
||||||
|
. Text.replace "ò" "o"
|
||||||
|
. Text.replace "ò" "o"
|
||||||
|
. Text.replace "ó" "o"
|
||||||
|
. Text.replace "Ü" "Ue"
|
||||||
|
. Text.replace "ü" "ue"
|
||||||
|
. Text.replace "ù" "u"
|
||||||
|
. Text.replace "ú" "u"
|
||||||
|
. Text.replace "û" "u"
|
||||||
|
. Text.replace "ë" "e"
|
||||||
|
. Text.replace "ê" "e"
|
||||||
|
. Text.replace "è" "e"
|
||||||
|
. Text.replace "é" "e"
|
||||||
|
. Text.replace "ï" "i"
|
||||||
|
. Text.replace "î" "i"
|
||||||
|
. Text.replace "ì" "i"
|
||||||
|
. Text.replace "í" "i"
|
||||||
|
. Text.replace "ß" "ss"
|
||||||
|
. Text.replace "ç" "c"
|
||||||
|
. Text.replace "ş" "s"
|
||||||
|
. Text.replace "ğ" "g"
|
||||||
|
. Text.replace "ñ" "n"
|
||||||
|
|
||||||
-- | Convert text as it is to Html, may prevent ambiguous types
|
-- | Convert text as it is to Html, may prevent ambiguous types
|
||||||
-- This function definition is mainly for documentation purposes
|
-- This function definition is mainly for documentation purposes
|
||||||
text2Html :: Text -> Html
|
text2Html :: Text -> Html
|
||||||
|
|||||||
@ -278,7 +278,8 @@ sendLetter printJobName pdf (printJobRecipient, printJobSender) printJobCourse p
|
|||||||
nameSender = abbrvName <$> sender
|
nameSender = abbrvName <$> sender
|
||||||
nameCourse = CI.original . courseShorthand <$> course
|
nameCourse = CI.original . courseShorthand <$> course
|
||||||
nameQuali = CI.original . qualificationShorthand <$> quali
|
nameQuali = CI.original . qualificationShorthand <$> quali
|
||||||
let jobFullName = T.replace " " "-" (T.intercalate "_" . catMaybes $ [Just printJobName, nameQuali, nameCourse, nameSender, nameRecipient])
|
let jobFullName = text2asciiAlphaNum $
|
||||||
|
T.replace " " "-" (T.intercalate "_" . catMaybes $ [Just printJobName, nameQuali, nameCourse, nameSender, nameRecipient])
|
||||||
printJobFilename = T.unpack $ jobFullName <> ".pdf"
|
printJobFilename = T.unpack $ jobFullName <> ".pdf"
|
||||||
-- printJobFile <- sinkFileDB True $ yield $ LBS.toStrict pdf -- for PrintJobFile :: FileContentReference use this code
|
-- printJobFile <- sinkFileDB True $ yield $ LBS.toStrict pdf -- for PrintJobFile :: FileContentReference use this code
|
||||||
printJobFile = LBS.toStrict pdf
|
printJobFile = LBS.toStrict pdf
|
||||||
|
|||||||
Reference in New Issue
Block a user