From: Georg Baum Date: Tue, 30 Dec 2014 12:30:40 +0000 (+0100) Subject: Make macro xhtml export more secure X-Git-Tag: 2.2.0alpha1~1402 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=33b059bd9d98e725500c48cccc855d89986223b3;p=features.git Make macro xhtml export more secure Actually I wanted to do that in cc87f8100 but forgot to adjust the original solution completely. Now we do not search for an arbitrary latexkeys instance which just happens to have the same name as the macro, but we only use the symbol that was explicitly set for global macros. --- diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp index d94c018166..24c9e07a5e 100644 --- a/src/mathed/MacroTable.cpp +++ b/src/mathed/MacroTable.cpp @@ -119,6 +119,20 @@ string const MacroData::requires() const } +docstring const MacroData::xmlname() const +{ + if (sym_) + return sym_->xmlname; + return docstring(); +} + + +char const * MacroData::MathMLtype() const +{ + return sym_ ? sym_->MathMLtype() : 0; +} + + void MacroData::unlock() const { --lockCount_; diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h index 1c9decc3e7..97029a3df0 100644 --- a/src/mathed/MacroTable.h +++ b/src/mathed/MacroTable.h @@ -62,6 +62,10 @@ public: /// std::string const requires() const; /// + docstring const xmlname() const; + /// + char const * MathMLtype() const; + /// void setSymbol(latexkeys const * sym) { sym_ = sym; } /// lock while being drawn to avoid recursions diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index db64c83953..c733952861 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -793,12 +793,11 @@ void MathMacro::maple(MapleStream & os) const void MathMacro::mathmlize(MathStream & os) const { - MathWordList const & words = mathedWordList(); - MathWordList::const_iterator it = words.find(name()); - if (it != words.end()) { - docstring const xmlname = it->second.xmlname; + LATTEST(macro_); + if (macro_) { + docstring const xmlname = macro_->xmlname(); if (!xmlname.empty()) { - char const * type = it->second.MathMLtype(); + char const * type = macro_->MathMLtype(); os << '<' << type << "> " << xmlname << " /<" << type << '>'; return; @@ -815,10 +814,9 @@ void MathMacro::mathmlize(MathStream & os) const void MathMacro::htmlize(HtmlStream & os) const { - MathWordList const & words = mathedWordList(); - MathWordList::const_iterator it = words.find(name()); - if (it != words.end()) { - docstring const xmlname = it->second.xmlname; + LATTEST(macro_); + if (macro_) { + docstring const xmlname = macro_->xmlname(); if (!xmlname.empty()) { os << ' ' << xmlname << ' '; return;