@@ -479,20 +479,26 @@ filePathToRelType path docXmlPath =
479479 then Just InDocument
480480 else Nothing
481481
482−relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship
483−relElemToRelationship relType element | qName (elName element) == "Relationship" =
482+relElemToRelationship :: FilePath -> DocumentLocation -> Element
483+ -> Maybe Relationship
484+relElemToRelationship fp relType element | qName (elName element) == "Relationship" =
484485 do
485486 relId <- findAttr (QName "Id" Nothing Nothing) element
486487 target <- findAttr (QName "Target" Nothing Nothing) element
487− return $ Relationship relType relId target
488−relElemToRelationship _ _ = Nothing
488+ -- target may be relative (media/image1.jpeg) or absolute
489+ -- (/word/media/image1.jpeg); we need to relativize it (see #7374)
490+ let frontOfFp = T.pack $ takeWhile (/= '_') fp
491+ let target' = fromMaybe target $
492+ T.stripPrefix frontOfFp $ T.dropWhile (== '/') target
493+ return $ Relationship relType relId target'
494+relElemToRelationship _ _ _ = Nothing
489495
490496filePathToRelationships :: Archive -> FilePath -> FilePath -> [Relationship]
491497filePathToRelationships ar docXmlPath fp
492498 | Just relType <- filePathToRelType fp docXmlPath
493499 , Just entry <- findEntryByPath fp ar
494500 , Just relElems <- parseXMLFromEntry entry =
495− mapMaybe (relElemToRelationship relType) $ elChildren relElems
501+ mapMaybe (relElemToRelationship fp relType) $ elChildren relElems
496502filePathToRelationships _ _ _ = []
497503
498504archiveToRelationships :: Archive -> FilePath -> [Relationship]