Commit graph

900 commits

Author SHA1 Message Date
jenkins-bot
079d61fb79 Merge "Remove "only newlines in trailer" special case for category/language links" 2017-09-29 22:20:52 +00:00
jenkins-bot
a5b41a26b6 Merge "Fix link prefix/suffixes around Category and Language links (take 2)." 2017-09-19 16:59:58 +00:00
Fomafix
b6c895ddc5 Do not double decode HTML entities for IDs
* in links (T103714)
* in indicators (T104196)

This change removes the automatic Sanitizer::decodeCharReferences from
Sanitizer::escapeId and Sanitizer::escapeIdInternal. Where decoding of
HTML entities are wanted an explicit call to
Sanitizer::decodeCharReferences is added.

Explicit decode HTML entities in non local autocomments. (T104311)

Bug: T103714
Bug: T104196
Bug: T104311
Change-Id: I88e8e2077e6f5eec2b232391f7818370894a62dc
2017-09-12 15:42:17 +02:00
jenkins-bot
2480aae0c9 Merge "Show a warning in edit preview when a template loop is detected" 2017-09-11 18:26:11 +00:00
C. Scott Ananian
5676481c6d Remove "only newlines in trailer" special case for category/language links
This special case complicates wikitext semantics and ought to be
unnecessary.  Parsoid doesn't include this special case; if this patch
to the PHP parser isn't merged, we should write one for Parsoid to
implement the missing special case logic.

Bug: T175416
Change-Id: I3865c51b21de9d63ac5d06dcc3a3fa9108129d6c
2017-09-08 23:44:42 -04:00
C. Scott Ananian
6d5fd8077f Fix link prefix/suffixes around Category and Language links (take 2).
Previous attempt was I943cd9bec0855d9a326b0b50739d686a29995370, reverted in
e687f2da3e due to T174639.

There's still a weird behavior with newline stripping between links, which
I'll try to tackle in a follow-on patch (T175416).

Bug: T2087
Bug: T10897
Bug: T87753
Bug: T174639
Change-Id: I8228cdd3b80faf899000adb511a983edc454bc76
2017-09-08 16:12:21 -04:00
jenkins-bot
c15f569fce Merge "Revert "Fix link prefix/suffixes around Category and Language links."" 2017-09-01 00:57:54 +00:00
Tim Starling
e687f2da3e Revert "Fix link prefix/suffixes around Category and Language links."
This reverts commit c66c9aa535.

Bug: T174639
Change-Id: Ibf6d3780f384ba8edc80bf28c893f1aee8ce28a8
2017-09-01 00:47:32 +00:00
Kunal Mehta
844d724621 Avoid using deprecated Title::canTalk()
Change-Id: Ibd224f9de595435524e683262882c9ebf2761abf
2017-08-29 12:36:33 -07:00
Matthew Bowker
a296331541 Remove two deprecated functions and one depreciated variable in a function call within Parser.php
* Parser::getRandomString() (deprecated in 1.26) was removed.
* Parser::uniqPrefix() (deprecated in 1.26) was removed.
* Parser::extractTagsAndParams() now only accepts three arguments.  The fourth, $uniq_prefix was deprecated in 1.26 and has now been removed.

Bug: T61113
Change-Id: I7333fff4eb8b9a754b4596992f2a69bbdaac664d
2017-08-22 18:14:14 -05:00
C. Scott Ananian
c66c9aa535 Fix link prefix/suffixes around Category and Language links.
Bug: T2087
Bug: T10897
Bug: T87753
Change-Id: I943cd9bec0855d9a326b0b50739d686a29995370
2017-08-15 13:13:12 -04:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
jenkins-bot
3b5b239e85 Merge "Make multiple colons escaping interlanguage links invalid, consistently" 2017-07-11 15:19:17 +00:00
Aaron Schulz
7ff8529984 Avoid high edit stash TTLs when a user signature was used
This adds a new ParserOuput user-signature tracking flag.

Bug: T84843
Change-Id: I77de05849c15e17ee2b9b31b34172f4b6a49a38e
2017-07-06 16:34:26 -07:00
Arlo Breault
0e1b52a40e Make multiple colons escaping interlanguage links invalid, consistently
* Right now, one or two are permitted.  This patch limits it to one.
   The current behaviour seems more a byproduct of refactoring than an
   explicit goal.

 * Note that this will break links on a handful of pages surfaced in
   Parsoid's roundtrip testing.

Change-Id: Icabd34bbf15781bb891bd8e0c079d1a65eb28595
2017-07-06 17:09:25 -04: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
jenkins-bot
3f849d695f Merge "Parser: Emit deprecation warnings for ParserLimitReport hook" 2017-06-26 15:05:22 +00:00
jenkins-bot
325e344774 Merge "Parser: Ensure function and tag hook callbacks are callable upon registration" 2017-06-25 10:24:58 +00:00
daniel
5d528f39d8 Parser: Ensure function and tag hook callbacks are callable upon registration
This is to safeguard against issues like T167238, where the callback was invalid,
but was only noticed when the magic word was used in an article.

In general, type checks should be applied when things get
registered for later use. Fail early, stay sane.

Change-Id: Ifb7005ee214829c98cec534261c0db7d13f50f35
2017-06-25 10:11:12 +00:00
Kunal Mehta
613ae1c3f2 Parser: Emit deprecation warnings for ParserLimitReport hook
Change-Id: I351f0867132acf8d5cc9ee51b575744445b28b77
2017-06-23 17:37:31 -07:00
Matěj Suchánek
43c13e7304 Show a warning in edit preview when a template loop is detected
Follow-up to Ib888634af.

Bug: T162149
Change-Id: I870dc22c984c900568ccacdc88d1bd31194394e1
2017-06-16 10:16:11 +02:00
jenkins-bot
3cb14f56bd Merge "Show dimensions in TraditionalImageGallery" 2017-06-15 17:16:13 +00:00
jenkins-bot
c5fa9b4e64 Merge "Parser: Better debugging of lock errors ("Did you call Parser::parse recursively?")" 2017-05-30 19:01:45 +00:00
Bartosz Dziewoński
baab085b32 Parser: Better debugging of lock errors ("Did you call Parser::parse recursively?")
Save the backtrace when locking, so that if some code tries locking again,
we can print the lock owner's backtrace for easier debugging.

Change-Id: I6e352b4aa5e7cb35825a66592f6c066d9e8b95c9
2017-05-23 14:50:13 +02:00
Timo Tijhof
c7e00974c7 Move loading of mediawiki.toc from Parser to Skin
This was the only addModules() call ever to be inside Parser.
Introduced in a54ef1a203. Prior to that, mediawiki.toc had always been loaded
by OutputPage (via mediawiki.util; and before that, via wikibits).

This patch restores that, and also fixes T130632 by making OutputPage get
it from the Skin, instead of hardcoding this somewhere in addParserOutput().

* Remove deprecated method OutputPage::enableTOC().
* Move mEnableTOC to addParserOutputText().

Bug: T130632
Change-Id: Iaad84d241a4c4348c712ac1087a664b8c9c46da4
2017-05-21 19:06:43 +02:00
Brad Jorsch
1aac0a2992 Wrap parser output in <div class="mw-parser-output">
This will allow CSS to target just the parser output, without also
accidentally targeting the edit form, diff tables, and so on.

Bug: T37247
Change-Id: If4eb5bf71f94fa366ec4eddb6964e8f4df6b824a
Depends-On: I330c6aa4aaee045614b1801ed34bc9e03be69650
Depends-On: I52a518fa44e017841fe78474012cd69823e0a41d
2017-05-08 05:32:03 +00:00
Umherirrender
84132a2613 Remove unused var assign in Parser::getTemplateDom
Change-Id: If11d7a2568d4235df6888e4001500bdf45f58eae
2017-05-02 21:18:54 +02:00
Umherirrender
bf51e3542b Add grep infos to Parser::getImageParams
Comments for grep makes searching easier

Change-Id: I98e93baf6bd89df36185d535d6e63c51c6f65bc9
2017-04-14 23:42:15 +02:00
Brian Wolff
17e7bc0235 SECURITY: Always normalize link url before adding to ParserOutput
Move link normalization directly into addExternalLink() method,
since you always need to do it - having it separate is just
inviting people to forget to normalize a link.

Additionally, links weren't properly registered for <gallery>.
This was somewhat unnoticed, as the call to recursiveTagParse()
would register free links, but it wouldn't work for example with
protocol relative links.

Issue originally reported by MZMcBride.

Bug: T48143
Change-Id: I557fb3b433ef9d618097b6ba4eacc6bada250ca2
2017-04-06 13:44:44 -07:00
Arlo Breault
aea349488c Valid tags on a gallery should correspond to unordered list
* This was introduced in 4d3446a8e3 when galleries were tables.
   However, in 05579cf0e6, it switched to ul's, but missed updating the
   sanitization.

 * As an example, the test shows that summary is currently wrongly
   permitted.

Change-Id: I8c52477dc65499d0c8a1ee5cc661a5f9ae78cc07
2017-04-01 09:59:21 -04:00
Matěj Suchánek
ec25c79139 Add a tracking category when a template loop is detected
Bug: T160743
Change-Id: Ib888634af281fc2347eaa389db4141782a98c15c
2017-03-17 11:52:38 +00:00
Matthias Mullie
ebb1680359 Show dimensions in TraditionalImageGallery
Bug: T121869
Change-Id: Ie2cb3f1594302f1726ae3d9d2d668c81b7e6b0f1
2017-03-07 13:09:00 +01:00
C. Scott Ananian
3e32d21210 Strip U+0000 in wikitext
U+0000 is not allowed in HTML5, there's no reason to allow it in wikitext.

It simplifies our code if we can just strip them at the start.  Strip in
PST as well so they don't sneak into our database either.

Tweaked the EXT_LINK URLs to account for the fact that invalid characters
get transformed into U+FFFD when using Preprocessor_DOM.  See 73649741ed
(r65967) for context on that change.

Bug: T159174
Change-Id: I3f67e92b61aacc87a40c3662085c84d1dac08bfb
2017-03-06 22:23:38 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Eddie Greiner-Petter
635040c91d Fixed documentation on Parser::getVariableValue
$index is definitely not a int here, see the big switch( $index )-case
statement below. It switches for strings, not numbers. Also, note that
this is lowercase, one might expect it to be uppercase as this is how
magic words are written in wikitext.

Bug: T96633
Change-Id: Iea93c3796fdee4ed7abbb7608e89b627ca95aead
2017-02-18 22:41:12 +00:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
This, that and the other
79cbecae83 Parser: Trim leading whitespace from links before checking for leading :
The leading spaces on the link only cause us problems, such as for the
$noforce check 20 lines later.

Bug: T129218
Change-Id: I93a8da1f73b38fa3da362f8f27479b3039ed3f13
2017-01-21 23:55:02 +00:00
Max Semenik
8cf5c2a37c Remove deprecated Parser::replaceUnusualEscapes()
Deprecated since 1.24, no callers.

Change-Id: Ib780f1a7b77d3ce624112f59c8e57820fecb6bf2
2017-01-18 19:19:00 -08:00
divadsn
e8d13ad1a2 Add a new {{PAGELANGUAGE}} variable for use in wikitext
Returns the language code of the page being parsed.

Bug: T59603
Change-Id: I229edd6251cf1120b3395d1811dbb9d96d9cd8ee
2017-01-07 02:03:53 +00:00
Aaron Schulz
b03b387e5a Include JS variable for NewPP report
Adapted from reverted commit b7c4c8717f.

Bug: T110763
Change-Id: If249b679c534879bfac622592a1d2fa913a0cf9d
2017-01-05 19:11:38 -08:00
jenkins-bot
704f307289 Merge "parser: Update outdated comment about ImageGallery" 2017-01-05 23:06:57 +00:00
Fomafix
d2997347a2 PHP code style: No space after unary not operator
Change-Id: I4d3df0cfcda4d88e405164123893e57786fbe15e
2017-01-05 16:00:59 +00:00
Timo Tijhof
7cd37c9f0e parser: Update outdated comment about ImageGallery
Follows-up f90634a6.

Change-Id: Ic17dc03cc37b85f222f3bb525e4cb39afc6f22ae
2017-01-03 18:15:40 -08:00
C. Scott Ananian
23fd64afde Don't parse language converter markup as a cell parameter in tables.
Bug: T153140
Change-Id: I799363727162a0f337652b26bb69fe35c61a8553
2016-12-22 11:09:50 -05:00
C. Scott Ananian
ae934157b2 Protect -{...}- variant constructs in galleries
This also protects naked external links, which are internally surrounded by
`-{R|...}-` by LanguageConverter::markNoConversion.

Originally found in failed tests in I7fa2d85d6.

Bug: T54190
Change-Id: I9b099273203482ffb570a5654d8ba50c833e526d
2016-12-20 22:14:37 +00:00
C. Scott Ananian
51d54b4b91 Protect -{...}- variant constructs in images.
A protected version of explode is factored out as
`StringUtils::delimiterExplode`, since it will be used in follow-up
patches in this series.  The `delimiterExplode` implementation creates
an intermediate array of the exploded results, which is reasonable as
the number of image options is small; but since an Iterator is
returned the implementation can be upgraded in the future (at the cost
of additional complexity) to avoid this.  The additional code in that
case would be similar to ExplodeIterator.

Bug: T146305
Change-Id: I1327685e9e8c07ef476dceaa6f6dae4ba40989ef
2016-12-20 22:08:36 +00:00