From 7834b564f4d7ae7650dc380479f86e9da4301848 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Fri, 16 Jun 2017 09:11:24 -0400 Subject: [PATCH] handle absolute relationship targets the correct way --- source/detail/serialization/xlsx_consumer.cpp | 10 ++++++++-- source/packaging/manifest.cpp | 5 ----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index 0b549855..81324503 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -187,10 +187,16 @@ std::vector xlsx_consumer::read_relationships(const path &part) const auto target_mode = parser.attribute_present("TargetMode") ? parser.attribute("TargetMode") : xlnt::target_mode::internal; + auto target = xlnt::uri(parser.attribute("Target")); + + if (target.path().is_absolute() && target_mode == target_mode::internal) + { + target = uri(target.path().relative_to(path(part.string()).resolve(path("/"))).string()); + } + relationships.emplace_back(parser.attribute("Id"), parser.attribute("Type"), - xlnt::uri(part.string()), xlnt::uri(parser.attribute("Target")), - target_mode); + xlnt::uri(part.string()), target, target_mode); expect_end_element(qn("relationships", "Relationship")); } diff --git a/source/packaging/manifest.cpp b/source/packaging/manifest.cpp index 64aeaa67..13e8590d 100644 --- a/source/packaging/manifest.cpp +++ b/source/packaging/manifest.cpp @@ -39,11 +39,6 @@ void manifest::clear() path manifest::canonicalize(const std::vector &rels) const { - if (rels.back().target().path().is_absolute()) - { - return rels.back().target().path().relative_to(path("/")); - } - xlnt::path relative; for (auto component : rels)