Page MenuHomePhabricator

Parsoid infinite recursion due to template loop involving <ref>
Closed, ResolvedPublic


As reported on T88915, Parsoid goes into an infinite loop with e.g. [[Template:CircularRef]] containing "<ref>{{CircularRef}}</ref>". This is because Parsoid lacks circular template reference checks.

If there is no <ref>, then Parsoid is protected by the fact that MW's Parser::preprocess() will mangle invocations of circular references. But MW does not guarantee the absence of circular references in its output.

Note that there is no API call inside the loop . After the first iteration, further expansions hit Parsoid's pageCache.

Event Timeline

tstarling raised the priority of this task from to High.
tstarling updated the task description. (Show Details)
tstarling added subscribers: tstarling, Arlolra, ssastry and 3 others.

Given, page cache shouldn't be involved.

Because extensions aren't processed by the preprocessor and preprocessor shouldn't be looking into extension source since the text inside the extension tags need not be wikitext, I see how MW api cannot guarantee absence of circular references. So, it makes sense to detect this and fix this in Parsoid.

My analysis of how MW deals with this test case was not quite correct. Actually the Cite extension is responsible for avoiding infinite recursion in this case. Cite allows <ref> inside <ref> only in certain non-recursive special cases. Parsoid should do the same.

Callers of Parser::recursiveTagParse() need to do their own recursion checks, since $frame->loopCheckHash is not preserved.

sqwiki:Marsi is another instance where circular ref checks are missing in Parsoid

Arlolra lowered the priority of this task from High to Medium.Jun 18 2016, 6:01 PM

Change 325882 had a related patch set uploaded (by Arlolra):
T104523: Prevent infinite recursion

Change 325882 merged by jenkins-bot:
T104523: Prevent infinite recursion