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.
This commit is contained in:
Georg Baum 2014-12-30 13:30:40 +01:00
parent b0361fb3c5
commit 33b059bd9d
3 changed files with 25 additions and 9 deletions

View 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_;

View 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

View 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;