14 return Parser::MARKER_PREFIX .
'-blah-' . sprintf(
'%08X', $i++ ) . Parser::MARKER_SUFFIX;
17 private static function getWarning( $message, $max =
'' ) {
18 return "<span class=\"error\">($message: $max)</span>";
24 $ss->addNoWiki( $marker,
'<>' );
25 $text =
"x{$marker}y";
26 $text = $ss->unstripGeneral( $text );
27 $text = str_replace(
'<',
'', $text );
28 $text = $ss->unstripNoWiki( $text );
29 $this->assertSame(
'x<>y', $text );
35 $ss->addGeneral( $marker,
'<>' );
36 $text =
"x{$marker}y";
37 $text = $ss->unstripNoWiki( $text );
38 $text = str_replace(
'<',
'', $text );
39 $text = $ss->unstripGeneral( $text );
40 $this->assertSame(
'x<>y', $text );
47 $ss->addNoWiki( $mk1,
'<1>' );
48 $ss->addGeneral( $mk2,
'<2>' );
49 $text =
"x{$mk1}{$mk2}y";
50 $text = str_replace(
'<',
'', $text );
51 $text = $ss->unstripBoth( $text );
52 $this->assertSame(
'x<1><2>y', $text );
66 $ss =
new StripState(
null, [
'depthLimit' => 2 ] );
68 for ( $i = 0; $i < $depth; $i++ ) {
70 $ss->addNoWiki( $mk,
"={$text}=" );
73 $text = $ss->unstripNoWiki( $text );
74 $this->assertSame( $expected, $text );
78 $ss =
new StripState(
null, [
'depthLimit' => 2 ] );
80 $ss->addNoWiki( $mk, $mk );
81 $text = $ss->unstripNoWiki( $mk );
82 $this->assertSame( self::getWarning(
'parser-unstrip-loop-warning' ), $text );
89 [ 2, str_repeat( self::getWarning(
'unstrip-size-warning', 5 ), 2 ) ]
95 $ss =
new StripState(
null, [
'sizeLimit' => 5 ] );
97 for ( $i = 0; $i < $depth; $i++ ) {
99 $ss->addNoWiki( $mk, $text );
102 $text = $ss->unstripNoWiki( $text );
103 $this->assertSame( $expected, $text );
107 for ( $i = 1; $i < 4; $i++ ) {
115 $ss =
new StripState(
null, [
'depthLimit' => 5,
'sizeLimit' => $sizeLimit ] );
117 for ( $i = 0; $i < $depth; $i++ ) {
119 $ss->addNoWiki( $mk, $text );
122 $text = $ss->unstripNoWiki( $text );
123 $report = $ss->getLimitReport();
128 $this->assertSame( [ $depth - 1, 5 ],
$messages[
'limitreport-unstrip-depth'] );
131 strlen( $this->
getMarker() ) * 2 * ( pow( 2, $depth ) - 2 ) + pow( 2, $depth ),
134 $messages[
'limitreport-unstrip-size' ] );