Page MenuHomePhabricator

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

Description

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 created this task.Jul 2 2015, 2:03 AM
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 https://phabricator.wikimedia.org/T88915#1223303, 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.

Arlolra moved this task from Backlog to In Progress on the Parsoid board.Jul 7 2015, 3:16 AM

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

ssastry moved this task from In Progress to Next Up on the Parsoid board.Dec 17 2015, 5:35 PM
Arlolra claimed this task.Apr 8 2016, 8:18 PM
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

https://gerrit.wikimedia.org/r/325882

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

https://gerrit.wikimedia.org/r/325882

Arlolra closed this task as Resolved.Dec 12 2016, 11:32 PM