]> git.lyx.org Git - features.git/commitdiff
Make macro xhtml export more secure
authorGeorg Baum <baum@lyx.org>
Tue, 30 Dec 2014 12:30:40 +0000 (13:30 +0100)
committerGeorg Baum <baum@lyx.org>
Tue, 30 Dec 2014 12:30:40 +0000 (13:30 +0100)
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.

src/mathed/MacroTable.cpp
src/mathed/MacroTable.h
src/mathed/MathMacro.cpp

index d94c018166e8a898c4db4d5bbc8aa64815fc564f..24c9e07a5eacaef91d41dd9f887d0f78bc60338a 100644 (file)
@@ -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_;
index 1c9decc3e7bef8adb43a91db5fafcbb4173acd84..97029a3df00f52a004026668597d952cb63f5ce4 100644 (file)
@@ -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
index db64c839535b4808fe41bbf8059ae139930d22f5..c7339528614cc4f571570fbe799e0dd3ce19924f 100644 (file)
@@ -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;