diff --git a/src/Handler/Utils/Submission.hs b/src/Handler/Utils/Submission.hs index ee7e7fc56..c6bce6821 100644 --- a/src/Handler/Utils/Submission.hs +++ b/src/Handler/Utils/Submission.hs @@ -678,12 +678,13 @@ sinkMultiSubmission userId isUpdate = do acc (Just sId, fp) segment = return (Just sId, fp ++ [segment]) acc (Nothing , fp) segment = do let - tryDecrypt (Text.pack -> ciphertext) + segments' = filter (not . Text.null) . Text.split (flip Set.notMember cryptoIdChars . CI.mk) $ Text.pack segment + tryDecrypt ciphertext | Just cID <- fromPathPiece ciphertext = do sId <- decrypt (cID :: CryptoFileNameSubmission) Just sId <$ get404 sId | otherwise = return Nothing - msId <- lift (lift (tryDecrypt segment) `catches` [ E.Handler handleCryptoID, E.Handler (handleHCError $ Right fileTitle) ]) + Alt msId <- lift . flip foldMapM segments' $ \seg -> Alt <$> lift (tryDecrypt seg) `catches` [ E.Handler handleCryptoID, E.Handler (handleHCError $ Right fileTitle) ] return (msId, fp) (msId, (joinPath -> fileTitle')) <- foldM acc (Nothing, []) $ splitDirectories fileTitle case msId of @@ -708,6 +709,9 @@ sinkMultiSubmission userId isUpdate = do handleCryptoID :: CryptoIDError -> _ (Maybe a) handleCryptoID _ = return Nothing + cryptoIdChars :: Set (CI Char) + cryptoIdChars = Set.fromList . map CI.mk $ "uwa" ++ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" + submissionMatchesSheet :: TermId -> SchoolId -> CourseShorthand -> SheetName -> CryptoFileNameSubmission -> DB SubmissionId submissionMatchesSheet tid ssh csh shn cid = do