StarCitizenTools / mediawiki-extensions-TabberNeue

A MediaWiki extension that allows wiki to create tabs.
https://www.mediawiki.org/wiki/Extension:TabberNeue
GNU General Public License v3.0
10 stars 15 forks source link

Tabs can no longer contain square brackets in their names #158

Closed alex4401 closed 2 months ago

alex4401 commented 2 months ago

Hi,

There seems to be a regression since v1.8.1, introduced in 7f7589999582e56a1dcf0e5af02ba12e6223a17f (feat: add support for nested tabbers in Codex (#95)), that results in the inability to create tabs that contain ], [ in their names. At wiki.gg we're using version v1.9.1 with patches for #151, but I reproduced this bug in the latest v2 version too. We're using legacy, non-Codex tabbers.

Reproduction

For a page consisting of the following wikitext:

<tabber>
a=a|-|
a>=a|-|
a<=a|-|
a[]=a|-|
b=c|-|
]=a|-|
[=a
</tabber>

behaviour is as follows:

Cause

Seems like the last line of the following breaks the tabs:

        $htmlTabs = preg_replace( '/\\\n/', '', $htmlTabs );
        $htmlTabs = preg_replace( '/\\\*/', '', $htmlTabs );
        $htmlTabs = str_replace( [ '"[', ']"' ], [ '[', ']' ], $htmlTabs );

Notably, when the following HTML is generated:

<article class="tabber__panel" data-mw-tabber-title="a&lt;"><p>
a</p></article>
<article class="tabber__panel" data-mw-tabber-title="a[]"><p>
a</p></article>

the last replacement removes the double quote after ]:

-<article class="tabber__panel" data-mw-tabber-title="a[]"><p>
+<article class="tabber__panel" data-mw-tabber-title="a[]><p>

I don't have any context for those three lines, and can't suggest any patches.

(Internal reference for my fellow wiki.gg friends: WIKIDEV-150)

alistair3149 commented 2 months ago

Thanks for the detailed report. Those lines are probably legacy code that used to get around some of the weird wikitext parsing issue that we faced before, but it should no longer be needed.