Use splitDirectories
istead of splitPath
.
We were using `splitPath` in two places in the code where `splitDirectories` should have been used. This led to a test for `..` in paths in `extractMedia` failing, so that images with `..` in the path name could be extracted outside the directory specified by `extractMedia`. It also led a test for `media` in resource paths to fail in the docx reader.
This commit is contained in:
parent
7d56650e01
commit
d960282b10
2 changed files with 2 additions and 2 deletions
|
@ -80,7 +80,7 @@ insertMedia fp mbMime contents (MediaBag mediamap) =
|
||||||
uri = parseURI fp
|
uri = parseURI fp
|
||||||
newpath = if isRelative fp
|
newpath = if isRelative fp
|
||||||
&& isNothing uri
|
&& isNothing uri
|
||||||
&& ".." `notElem` splitPath fp
|
&& ".." `notElem` splitDirectories fp
|
||||||
then T.unpack fp'
|
then T.unpack fp'
|
||||||
else showDigest (sha1 contents) <> "." <> ext
|
else showDigest (sha1 contents) <> "." <> ext
|
||||||
fallback = case takeExtension fp of
|
fallback = case takeExtension fp of
|
||||||
|
|
|
@ -505,7 +505,7 @@ archiveToRelationships archive docXmlPath =
|
||||||
|
|
||||||
filePathIsMedia :: FilePath -> Bool
|
filePathIsMedia :: FilePath -> Bool
|
||||||
filePathIsMedia fp =
|
filePathIsMedia fp =
|
||||||
"media" `elem` splitPath (takeDirectory fp)
|
"media" `elem` splitDirectories (takeDirectory fp)
|
||||||
|
|
||||||
lookupLevel :: T.Text -> T.Text -> Numbering -> Maybe Level
|
lookupLevel :: T.Text -> T.Text -> Numbering -> Maybe Level
|
||||||
lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do
|
lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do
|
||||||
|
|
Loading…
Reference in a new issue