Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.
What is the scope of a definition? The whole html page?
I've created an issue on the MathJax issue tracker. I'm not sure there's a good solution to this problem aside from simply disabling \newcommand and \def. This problem will also crash LaTeX (at least the implementation I have installed right now).
What is the scope of a definition? The whole html page?
I think it's everything on the page below where the definition is made.
A limit on stack length during expansion should not be that hard to implement, and would not impair essentially no sensible latex expression on MO.
(If we could limit the scope of definitions to an answer, for example, we could all start pasting our favorite latex prologue when writing an answer... :) )
Davide has implemented a limit on the number of macro substitutions and a limit on the size of the string after substitution:
MAXMACROS: 10000, // maximum number of macro substitutions per equation
MAXBUFFER: 5*1024 // maximum size of TeX string to process
Faketestsite is currently running the branch with the fix, but MO is not. I invite you all to go experiment on Faketestsite to see if you can cause trouble of find unexpected behavior.
I've noted at the issue tracker one way to still cause a fair amount of trouble with \newcommand
.
Are those tunable by sites? I am pretty sure that anything with 20 macro substitutions in an equation in MO is evil...
Yes, they're tunable. I agree that 20 is probably a sufficiently big number for MAXMACROS.
The fix is now running on MO. You're welcome to go type $\newcommand{\x}{\x}\x$
in and see what happens (though you should clear your cache first, and it would really be better for you to run such experiments at faketestsite). I've brought MAXMACROS
down from 10000 to a more conservative 50. If this ever turns out to be too small, we can make it bigger.
One thing that wasn't clear to me before was the meaning of MAXMACROS
. It's the cap on the maximum number of macros that will be expanded in any given formula. So you might exceed the cap of 50 as follows:
$\newcommand{\Z}{\mathbb Z}
\newcommand{\Zp}{\Z/p\Z}$Consider the 11-tuple of groups $(\Zp,\Zp,\Zp,\Zp,\Zp,\Zp,\Zp,\Zp,\Zp,\Zp,\Zp)$
Each \Zp
results in five macro expansions:
one to convert \Zp
in to \Z/p\Z
,
two more to convert \Z/p\Z
into \mathbb Z/p\mathbb Z
, and
two more to conver \mathbb Z/p\mathbb Z
into {\bbFont Z}/p{\bbFont Z}
The single formula with 11 instances of \Zp
results in 55 macro expansions, so that formula breaks.
Allowing \renewcommand, for example, is just asking for trouble. See http://faketestsite.stackexchange.com/questions/151/let-me-test-mathjax I wonder if there is a sensible subset that could be allowed in public fora...
@Mariano: \renewcommand
is implemented as an exact synonym of \newcommand
, and \def
is also basically a synonym, but with slightly different syntax. I don't think it's worth worrying about this too much until it occurs in the wild, at which point we'll probably be able to handle it by simply getting angry with the perpetrator. You can only cause trouble with \renewcommand
if you can get your posts to appear above some worthwhile post. This is not something a troll can easily do, and certainly not something that can be done by a script.
What if you put it in a comment on the original question? Wouldn't that appear above any answer?
Yes, it would, but you'd have to earn enough rep to comment first.
True, I was just pedantically pointing out minor details. I suspect that the chance of this being used as a weapon against MO is very slight.
What worries me more is the probability of someone copying over all their basic macros and making the site slow to an absolute crawl for the rest of us.
Another thing also just occurred to me about these definitions. Heading on over to faketestsite, I see that I'm not the only one to think of this: http://faketestsite.stackexchange.com/questions/151/let-me-test-mathjax. To save people the bother of clicking on the link, it appears that \newcommand
s are global. That means that the \newcommand
s on one part of the page will affect what happens in another. Since the order matters, and the order can change (it can even be different for different users as some will order the entries by date, some by reputation), this is potentially quite a serious issue.
1 to 15 of 15