commit 33b059bd9d98e725500c48cccc855d89986223b3
Author: Georg Baum <[email protected]>
Date: Tue Dec 30 13:30:40 2014 +0100
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 d94c018..24c9e07 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 1c9decc..97029a3 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 db64c83..c733952 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;