diff options
| author | Martin Owens <doctormo@gmail.com> | 2016-10-01 21:30:34 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2016-10-01 21:30:34 +0000 |
| commit | 7d1184c85c47f1272da5b2ed7816efa685a73e83 (patch) | |
| tree | ed9ae3c5c2354de98b6e2417af7a2e6d334fe501 /src/extension/internal/svg.cpp | |
| parent | Update attributes list for rename of 'mesh' to 'meshgradient'. (diff) | |
| download | inkscape-7d1184c85c47f1272da5b2ed7816efa685a73e83.tar.gz inkscape-7d1184c85c47f1272da5b2ed7816efa685a73e83.zip | |
Add a prune method to saving svg files that removes Adobe's i:pgf tag.
Fixed bugs:
- https://launchpad.net/bugs/179679
(bzr r15141)
Diffstat (limited to 'src/extension/internal/svg.cpp')
| -rw-r--r-- | src/extension/internal/svg.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index a94bc2141..9cde90519 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -78,6 +78,28 @@ static void pruneExtendedNamespaces( Inkscape::XML::Node *repr ) } } +/* + * Similar to the above sodipodi and inkscape prune, but used on all documents + * to remove problematic elements (for example Adobe's i:pgf tag) only removes + * known garbage tags. + */ +static void pruneProprietaryGarbage( Inkscape::XML::Node *repr ) +{ + if (repr) { + std::vector<Inkscape::XML::Node *> nodesRemoved; + for ( Node *child = repr->firstChild(); child; child = child->next() ) { + if((strncmp("i:pgf", child->name(), 5) == 0)) { + nodesRemoved.push_back(child); + g_warning( "An Adobe proprietary tag was found which is known to cause issues. It was removed before saving."); + } else { + pruneProprietaryGarbage(child); + } + } + for ( std::vector<Inkscape::XML::Node *>::iterator it = nodesRemoved.begin(); it != nodesRemoved.end(); ++it ) { + repr->removeChild(*it); + } + } +} /** \return None @@ -246,6 +268,10 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE) || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE)); + // We prune the in-use document and deliberately loose data, because there + // is no known use for this data at the present time. + pruneProprietaryGarbage(rdoc->root()); + if (!exportExtensions) { // We make a duplicate document so we don't prune the in-use document // and loose data. Perhaps the user intends to save as inkscape-svg next. |
