Commit graph

45 commits

Author SHA1 Message Date
Kunal Mehta
1706d353ae Don't link wikilinks in section heading autocomments
Previously, a manually constructed autocomment in the form of
/* [[Some link]] */

would create a link to the the section, and then the "Some link" page.

After T165189 was implemented, the entire autocomment is now a link to
the section, so we're creating links inside of a link...which is
problematic. In most contexts (history and watchlist particularly), the
section link is more important than the title in the section heading, so
that's what we'll favor here.

It's worth noting that this situation is a manually created edge case.
Even if the section heading is a wikilink, the edit summary will
autofill a section autocomment without the double brackets.

We'll now render the double brackets ([[...]]) and not link them. This
is what the user literally typed, and matches the existing practice of
rendering templates in section headings with their literal syntax. And
as a bonus, it's still possible for user scripts such as wikEdDiff to
turn the rendered double brackets into a real link if users want.

Bug: T165189
Change-Id: Ib10679edd76c72a60d7e1c89fc8454166e34c463
2018-12-03 12:43:03 -08:00
Kunal Mehta
0c9cf24b05 Restore old HTML structure for history section links
A follow-up to 0a8e16d7cf thanks to Anomie's code review.

The section title is now inside <span dir="auto"> and <span
class="autocomment">, as before. $wgLang->getDirMark() between the arrow
and the text was restored.

Given the comment
 /* External links */ removed bogus entries
the HTML before 0a8e16d7cf looked like:
 <a href="#External_links">→</a>‎<span dir="auto"><span
 class="autocomment">External links: </span> removed bogus entries</span>
after this change, it will look like:
 <span dir="auto"><span class="autocomment"><a
 href="#External_links">→‎External links</a>: </span> removed bogus
 entries</span>

The issue of having links be inside other links will be addressed in a
separate patch.

Bug: T165189
Change-Id: I31d87a87ccaf50de58fdd0621c46133b2881b490
2018-12-03 12:42:56 -08:00
Bjornskjald
0a8e16d7cf Make "→" link to page section on History page larger by adding section name to it
Bug: T165189
Change-Id: I1f845592bd3de342fda84b60fc412055973950fd
2018-11-24 03:22:16 +00:00
Thiemo Kreuz (WMDE)
2c58fbaa29 Linker: more consistent whitespace parsing in formatLinksInComment
Try to paste and preview this in the wikitext as well as the summary
line: [[:a]] [[ :a]]

The wikitext will show "a a", but the summary line will show "a :a".
This is only a display issue, all 4 links correctly link to the
article [[A]].

Change-Id: I08253a6d0b55b9aa3eace519bbdc1a456400bf84
2018-09-06 17:19:32 +00:00
Kunal Mehta
03e7ae45bc Remove deprecated Linker::getLinkColour()
Change-Id: I1818d9eb369c620cc436c13446a5362816e8362d
2018-06-13 01:30:04 -07:00
Kunal Mehta
d78d6e23cf linker: Hard-deprecate LinkBegin and LinkEnd hooks
Change-Id: Ia1d766d019a2711c96e7c41913055774eff9f777
2018-06-10 12:00:15 -07:00
Umherirrender
67d420b302 Move @group and @covers tags in tests close to class
For @group and @covers tags there should be no newline between the
comment and the class

Change-Id: I7277df13a332cf4d74ffdd8748e3fbdc259610dc
2018-01-28 13:30:07 +01:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
jenkins-bot
f246973a44 Merge "Linker: Do not localize links to other wikis in comments" 2017-07-06 02:08:02 +00:00
Matěj Suchánek
922b85bad0 Linker: Do not localize links to other wikis in comments
The title, although it refers to a foreign page, is considered local
due to Title::isExternal() being false, hence it's namespace prefix
is localized.

We need to use the canonical namespace name instead.

Bug: T169221
Change-Id: I5e5f7d873b9497ca6c8853e7d8170a4f4f07c051
2017-07-05 18:56:27 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Moriel Schottlender
1fff06ad2d bidi-isolate usernames in Linker::userLink
Usernames can be in any script/language and include weak and neutral
characters like parentheses and dashes - these flip and make things
look very weird when displayed in the opposite directionality.

This fix adds <bdi> tags to isolate the username when we output user
links. This will affect displays like user personal tools, history
and diff view.

Also, fixing LogFormatterTestCase::removeSomeHtml() that expected
a very rigid html input (and thus failed with the new <bdi> wrapping)
to use strip_tags() instead.

Change-Id: I2db5f4b7d3a00726461eb6b699fbdf0ecd47a1cb
2016-08-31 17:44:06 -07:00
jenkins-bot
e305dd6ced Merge "Move Linker::getLinkColour() into LinkRenderer" 2016-07-18 16:16:07 +00:00
Kunal Mehta
b74c4b2f95 Improve @covers tags for LinkerTest
These hooks are now called from LinkRenderer, so make sure it is
covering the right code.

Change-Id: Ifaa28d471f585dce9d968cc1173c7fdceb408239
2016-05-27 19:30:42 -07:00
Kunal Mehta
5119236d4d Move Linker::getLinkColour() into LinkRenderer
* Rename to getLinkClasses() since it's not really returning colours,
  but CSS classes.
* Dependency inject LinkCache into LinkRenderer
* Update all callers of Linker::getLinkColour(), and mark it as
  deprecated (no other uses in Gerrit)
* Update a bunch of tests for new dependency

Change-Id: Id178e2dcc60b833ce2dbad4920896b93cabba1bf
2016-05-27 09:18:09 -07:00
Kunal Mehta
5f8a771f7e Add tests for Linker::getLinkColour()
Change-Id: Ic1553e21def47f5c4923ba747146b36b0b3ffdfc
2016-05-26 14:47:45 -07:00
Kunal Mehta
a95e8e7262 LinkRenderer: Re-implement noclasses as makePreloadedLink function
'noclasses' makes more sense as a per-link option rather than an
instance member of the LinkRenderer instance, since it depends entirely
on whether the calling code has preloaded the link classes.

Introduce LinkRenderer::makePreloadedLink() which makes this clear and
requires passing in the classes as a separate parameter. As a side-
effect, due to the way LinkRenderer::mergeAttribs() is implemented, the
'class' attribute will always appear before the 'title' attribute in the
final output.

Change-Id: I0545aa9d7139794bc22f9d3d6d6eccde003b2982
2016-05-26 00:24:06 -07:00
Kunal Mehta
c9219c4f81 LinkerTest: Fix passing test description to $this->assertEquals()
It was being passed to Linker::userLink() by accident.

Change-Id: I13ba5014193e91a467511259a0c7c1659d8bc0e6
2016-05-17 20:30:02 +00:00
Brian Wolff
ee4d5c6eed Remove support for $wgWellFormedXml=false
tl;dr: Having unnessary complexity in security critical code is bad.

* Extra options add extra complexity and maintenance burden
** Thus we should only have one html output mode. well formed = false
     was already vetoed in T52040, so lets go with WellFormed=true.
* Options which are used by very few people tend to get tested less
* Escaping is an area of code where we should be very conservative
* Having escaping rules depend on making assumptions about which
    characters various browsers consider "whitespace" is scary
* $wgWellFormedXml=false has had a negative security impact in the
    past (Usually not directly its fault, but has made other bugs
    more exploitable)
* Saving a couple bytes (even less bytes after gzip taken into
    account) is really not worth it in this context (imho).

Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
2016-05-12 17:40:01 -04:00
Kunal Mehta
e66d8905f8 Add tests for 'LinkBegin' hook
Change-Id: I663c25377fb899ea97ef959efac82dc836a9940a
2016-05-11 16:17:54 -07:00
Kunal Mehta
1facfab51b Add tests for 'LinkEnd' hook functionality
Change-Id: I5bd353756c0631b3dd1c214f814040d82d7c361f
2016-05-11 10:18:51 -07:00
Reedy
83fb19cb13 Swap the rest of array() -> []
Change-Id: I76a7259ed952a0673a1941f08b39b545211fba07
2016-03-30 22:04:58 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Amir E. Aharoni
c50cbe48ab Fix remaining Generic.Files.LineLength failures
Except the ones for which there is no clear way to fix
because of T114213.

Bug: T102614
Change-Id: I94a1fc7c890c82a36f0b51e42d311585c275775c
2015-10-03 17:23:07 +00:00
Amir E. Aharoni
bfdd3369c2 Fix Generic.Files.LineLength phpcs check in files under phpunit/includes
Bug: T102614
Change-Id: Iee3df5f064f595ecebe8210cc936bc3d20a122c9
2015-10-03 17:13:29 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Amir E. Aharoni
76ae9acec3 Make line shorter to pass phpcs in LinkerTest.php
There are other linkes here ythat will require a different treatment.

Bug: T102614
Change-Id: Ia0c75d11a85a931d37941471f9c9bdc16fda28e1
2015-09-26 18:20:11 +00:00
daniel
ef1f4af079 Allow Linker::formatComment to link to another wiki per default.
This also adds tests against injection to LinkerTest.

Bug: T111676
Change-Id: I757f2b91f3b50d789d04e530049c34b4628253e3
2015-09-15 18:10:33 +02:00
Marius Hoch
dd740a65dc Don't double escape in Linker::formatLinksInComment
Affected both the linked text and the actual URL.

For an example please see the ukwiki link on:
https://www.mediawiki.org/wiki/Special:CentralAuth/Admin

Follow-Up: Ibdedf087f85046646450367cbf1811db578d8f4b
Change-Id: Ie73796dcde4e0a096a6baa86a53245e6fe2b48b5
2015-01-15 18:14:42 +00:00
Marius Hoch
d14f6c0de3 Make Linker::formatLinksInComment format links to other wikis
Needed for CentralAuth.

Change-Id: Ibdedf087f85046646450367cbf1811db578d8f4b
2015-01-09 11:22:31 -08:00
Brad Jorsch
29951907f7 Format multiple autocomments in edit summaries
Before r39373, all autocomments in an edit summary were formatted. In
fixing a bug with page titles containing "/*" this was accidentally
broken.

To use a single preg_replace_callback call to replace multiple
autocomments, we need to make sure that the match of one autocomment
doesn't overlap the match of another, which means we can't have "(.*)"
before and after. But we do still need to detect whether there is
anything before or after. "(?=(.?))" and "(?<=(.?))" would do nicely,
except the latter isn't actually supported. "(?=(.))?" and "(?<=(.))?"
work too, but older versions of PCRE don't support that. They do,
however, support "(?:(?=(.)))?" and "(?:(?<=(.)))?", so that's what
we'll go with.

This change does change the values for $pre and $post passed to the
FormatAutocomments hook; extensions need to be updated to accept (and
not prepend/append) booleans for these parameters.

Bug: T18530
Bug: T70361
Change-Id: I36c3a9e548a4ef72f93974bb35f9add8c29e9287
2014-12-31 10:24:05 +11:00
Jeff Janes
7e3fcc39ea PHPUnit: Add Database tags
Several unit tests access the database, but did not declare
themselves in the Database @group.  This causes
"make databaseless" to fail needlessly.  Add the
missing tags.

tests/phpunit/includes/LinkerTest.php
tests/phpunit/includes/actions/ActionTest.php
tests/phpunit/includes/specials/ImageListPagerTest.php
tests/phpunit/includes/specials/SpecialMIMESearchTest.php
tests/phpunit/includes/title/MediaWikiPageLinkRendererTest.php

Other than ActionTest.php, these also are problematic in 1.23

Change-Id: I7c1c957e2194c13e48b7ba68d7529e5d89901875
2014-09-16 18:42:27 -07:00
Chad Horohoe
f129b1baf9 Limit test leakage, $wgCapitalLinks expected to be true
Change-Id: I0f837d29595abefaebeb67d6cc62ea48838d626a
2014-07-07 16:54:35 -07:00
aude
dfbc4d7f32 Set wgScript in LinkerTest
otherwise tests fail if you don't have this setting.

Change-Id: I598b83c348dc54908225ee398787bf300d473656
2014-06-24 09:39:17 +02:00
Bartosz Dziewoński
63ce38567c LinkerTest: A bunch of tests for Linker::formatComment and friends
Change-Id: Ie805d2945ddc1596545ef3f22d32b429caca8a27
2014-06-10 22:26:07 +02:00
Siebrand Mazeland
ce42915e0d Pass phpcs-strict on some test files (2/x)
Change-Id: Ia39fd107a554206927652b6e168faa0da501b362
2014-04-24 17:05:34 +02:00
Kunal Mehta
f2de3967d9 Add 'mw-anonuserlink' class for anonymous users
Bug: 43179
Change-Id: I57780e1045044e8532dc6defc4cca2e27434c055
2014-02-23 16:24:34 -08:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
Yuri Astrakhan
27d83878c0 Lots of spelling mistakes and phpdoc attributes
@throw->@throws
@returns->@return
@seealso->@see
@cover->@covers
etc

Change-Id: I9ae6bc3034e9790e2d66cd96473b923fe9ee7953
2013-03-10 23:16:28 -04:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
umherirrender
515253bc4c Set wgWellFormedXml for LinkerTest::testUserLink
Change-Id: I9ab370e2f23e0134741680ff620e8bb552496868
2012-12-09 11:56:45 +01:00
Platonides
a8440314f2 LinkerTest needs to set the wiki language to en.
The localisation of Special:Contributions break the
testUserLink otherwise.

Change-Id: I25a40356a96e03975d8ceca975449f7b064bca2b
2012-12-06 18:53:43 +01:00
csteipp
ebc73c7df7 (bug 36780) Improve display of IPv6 addresses
Also add partial tests for Linker::userLink()

Change-Id: I680a59bb0ec3ca1d85ed12b0debb3446c73a3aab
2012-11-26 23:00:33 +00:00