r93633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93632‎ | r93633 | r93634 >
Date:17:37, 1 August 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Fixes Bug #30149 - Handling of parentheses for Korean, Chinese and Japanese

Adapts the pipe trick with parens for fullwidth parentheses. Adds parsertests.

Patch from Dan Collins.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -3928,6 +3928,126 @@
39293929 !! end
39303930
39313931 !! test
 3932+pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, bug 30149)
 3933+!! options
 3934+pst
 3935+!! input
 3936+[[Article(context)|]]
 3937+[[Bar:Article(context)|]]
 3938+[[:Bar:Article(context)|]]
 3939+[[|Article(context)]]
 3940+[[Bar:X (Y) Z|]]
 3941+[[:Bar:X (Y) Z|]]
 3942+!! result
 3943+[[Article(context)|Article]]
 3944+[[Bar:Article(context)|Article]]
 3945+[[:Bar:Article(context)|Article]]
 3946+[[Article(context)]]
 3947+[[Bar:X (Y) Z|X (Y) Z]]
 3948+[[:Bar:X (Y) Z|X (Y) Z]]
 3949+!! end
 3950+
 3951+!! test
 3952+pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, bug 30149)
 3953+!! options
 3954+pst
 3955+!! input
 3956+[[Article (context)|]]
 3957+[[Bar:Article (context)|]]
 3958+[[:Bar:Article (context)|]]
 3959+[[|Article (context)]]
 3960+[[Bar:X (Y) Z|]]
 3961+[[:Bar:X (Y) Z|]]
 3962+!! result
 3963+[[Article (context)|Article]]
 3964+[[Bar:Article (context)|Article]]
 3965+[[:Bar:Article (context)|Article]]
 3966+[[Article (context)]]
 3967+[[Bar:X (Y) Z|X (Y) Z]]
 3968+[[:Bar:X (Y) Z|X (Y) Z]]
 3969+!! end
 3970+
 3971+!! test
 3972+pre-save transform: context links ("pipe trick") with parens and no space (Korean style, bug 30149)
 3973+!! options
 3974+pst
 3975+!! input
 3976+[[Article(context)|]]
 3977+[[Bar:Article(context)|]]
 3978+[[:Bar:Article(context)|]]
 3979+[[|Article(context)]]
 3980+[[Bar:X(Y)Z|]]
 3981+[[:Bar:X(Y)Z|]]
 3982+!! result
 3983+[[Article(context)|Article]]
 3984+[[Bar:Article(context)|Article]]
 3985+[[:Bar:Article(context)|Article]]
 3986+[[Article(context)]]
 3987+[[Bar:X(Y)Z|X(Y)Z]]
 3988+[[:Bar:X(Y)Z|X(Y)Z]]
 3989+!! end
 3990+
 3991+!! test
 3992+pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, bug 30149)
 3993+!! options
 3994+pst
 3995+!! input
 3996+[[Article(context)|]]
 3997+[[Bar:Article(context)|]]
 3998+[[:Bar:Article(context)|]]
 3999+[[|Article(context)]]
 4000+[[Bar:X (Y) Z|]]
 4001+[[:Bar:X (Y) Z|]]
 4002+!! result
 4003+[[Article(context)|Article]]
 4004+[[Bar:Article(context)|Article]]
 4005+[[:Bar:Article(context)|Article]]
 4006+[[Article(context)]]
 4007+[[Bar:X (Y) Z|X (Y) Z]]
 4008+[[:Bar:X (Y) Z|X (Y) Z]]
 4009+!! end
 4010+
 4011+!! test
 4012+pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, bug 30149)
 4013+!! options
 4014+pst
 4015+!! input
 4016+[[Article (context)|]]
 4017+[[Bar:Article (context)|]]
 4018+[[:Bar:Article (context)|]]
 4019+[[|Article (context)]]
 4020+[[Bar:X (Y) Z|]]
 4021+[[:Bar:X (Y) Z|]]
 4022+!! result
 4023+[[Article (context)|Article]]
 4024+[[Bar:Article (context)|Article]]
 4025+[[:Bar:Article (context)|Article]]
 4026+[[Article (context)]]
 4027+[[Bar:X (Y) Z|X (Y) Z]]
 4028+[[:Bar:X (Y) Z|X (Y) Z]]
 4029+!! end
 4030+
 4031+!! test
 4032+pre-save transform: context links ("pipe trick") with parens and no space (Korean style, bug 30149)
 4033+!! options
 4034+pst
 4035+!! input
 4036+[[Article(context)|]]
 4037+[[Bar:Article(context)|]]
 4038+[[:Bar:Article(context)|]]
 4039+[[|Article(context)]]
 4040+[[Bar:X(Y)Z|]]
 4041+[[:Bar:X(Y)Z|]]
 4042+!! result
 4043+[[Article(context)|Article]]
 4044+[[Bar:Article(context)|Article]]
 4045+[[:Bar:Article(context)|Article]]
 4046+[[Article(context)]]
 4047+[[Bar:X(Y)Z|X(Y)Z]]
 4048+[[:Bar:X(Y)Z|X(Y)Z]]
 4049+!! end
 4050+
 4051+!! test
39324052 pre-save transform: trim trailing empty lines
39334053 !! options
39344054 pst
Index: trunk/phase3/includes/parser/Parser.php
@@ -4320,9 +4320,9 @@
43214321 $tc = "[$wgLegalTitleChars]";
43224322 $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
43234323
4324 - $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( \\($tc+\\))\\|]]/"; # [[ns:page (context)|]]
4325 - $p4 = "/\[\[(:?$nc+:|:|)($tc+?)(($tc+))\\|]]/"; # [[ns:page(context)|]]
4326 - $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( \\($tc+\\)|)(, $tc+|)\\|]]/"; # [[ns:page (context), context|]]
 4324+ $p1 = "/\[\[(:?$nc+:|:|)($tc+?)(\s?\\($tc+\\))\\|]]/"; # [[ns:page (context)|]]
 4325+ $p4 = "/\[\[(:?$nc+:|:|)($tc+?)(\s?($tc+))\\|]]/"; # [[ns:page(context)|]]
 4326+ $p3 = "/\[\[(:?$nc+:|:|)($tc+?)(\s?\\($tc+\\)|)(, $tc+|)\\|]]/"; # [[ns:page (context), context|]]
43274327 $p2 = "/\[\[\\|($tc+)]]/"; # [[|page]]
43284328
43294329 # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"

Follow-up revisions

RevisionCommit summaryAuthorDate
r93764Follow up r93633. Allow only classic spaces.platonides16:23, 2 August 2011
r96042r93633 - remove duplicated testsmah21:17, 1 September 2011

Comments

#Comment by Platonides (talk | contribs)   16:24, 2 August 2011

I would have used just " ?" instead of "\s?". We don't need more odd cases about separating the title from parenthesis using a tab or a vertical tab. The provided tests still pass. I changed it on r93764.

#Comment by OverlordQ (talk | contribs)   16:48, 26 August 2011

Tests need unique names to pass the duplicate key constraint on test items.

#Comment by MarkAHershberger (talk | contribs)   21:19, 1 September 2011

good eye! those were duplicates, probably from patching more than once.

Status & tagging log