Commit graph

915 commits

Author SHA1 Message Date
jenkins-bot
bd78869618 Merge "No yoda conditions" 2018-12-09 01:34:23 +00:00
jenkins-bot
9ff8e0a946 Merge "Remove most support for configuring Tidy, including Raggett" 2018-12-05 18:59:50 +00:00
Subramanya Sastry
76396ff888 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 5eb1690104ff70e0bd090b5cb93900b4be766377

Change-Id: I051ff481147d9a2189442f885131b47a6c00d373
2018-12-03 16:05:28 -06:00
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
jenkins-bot
7ddab17aac Merge "Accept BCP 47 codes in LanguageConverter rules" 2018-11-27 18:49:25 +00:00
Subramanya Sastry
fbe6b633b7 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 463678ed5c83764a3558fec13cea07825a4fddd4

Change-Id: I5bd67b9f20ee9cda2c1141670ab140d65f8a2cc0
2018-11-27 12:10:47 -05:00
jenkins-bot
c984a1f2f8 Merge "Quoted attributes don't need to be followed by a space" 2018-11-27 16:21:41 +00:00
jenkins-bot
4077b57759 Merge "Parse wikitext in gallery caption" 2018-11-27 15:47:50 +00:00
C. Scott Ananian
f87898b488 Protect legacy URL parameter syntax in link and alt options
HTML doesn't allow certain semicolon-less HTML entities in attribute
values to avoid breaking legacy markup like:
  <a href="http://example.com?foo&param=bar">...</a>
(Note that the & in that URL is not properly entity-escaped as `&amp;`.)

Unlike wikitext, HTML generally allows semicolon-less legacy entities
in text.

Our alt and link option processing shove text through
Sanitizer::stripAllTags, which does entity decoding including these
legacy semicolon-less entities.  Wikitext doesn't allow semicolon-less
entities, so escape & characters where appropriate to protect alt/link
options and avoid breaking URLs.

This was a "regression" in how alt options were handled starting in
ddb4913f53 when we switched to using
Remex for Sanitizer::stripAllTags -- semicolon-less entities (previously
invalid in wikitext) were now being decoded when stripAllTags was
called on alt text.  This change became a problem when
ad80f0bca2 sent link option text through
Sanitizer::stripAllTags (with the new semicolon-less entity decode)
instead of PHP's strip_tags (which, in addition to its other faults,
doesn't do entity decode at all).  This suddenly started decoding
"non-wikitext" entities like `&para` inside URLs, breaking links.
Filed T210437 as a follow-up to consider changing the behavior
of Sanitizer::stripAllTags() globally to prevent it from decoding
semicolon-less entities for all callers.

Bug: T209236
Change-Id: I5925e110e335d83eafa9de935c4e06806322f4a9
2018-11-27 10:12:05 -05:00
Subramanya Sastry
72fd6adca7 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit c900a0c7dbd27cdba09d43971411e6849be73558

Change-Id: I7d7049e4cfbe50d7fe9c90894a6879e1694a3078
2018-11-26 10:15:12 -05: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
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01:00
C. Scott Ananian
6db35b3c98 Remove most support for configuring Tidy, including Raggett
Remex is pure PHP so there is no reason to use an external tidy any
more. Configuration variables and implementation classes were
deprecated in 1.32 or earlier.  We've kept only $wgTidyConfig
which can be used for experimental features or debugging Remex.

Bug: T198214
Change-Id: I99d48f858d97b6e1d1e6cd76a42c960cc2c61f9f
2018-11-15 12:22:06 -05:00
Brad Jorsch
d099bb6f95 Drop the image_comment_temp table
It is no longer used.

Bug: T188132
Change-Id: Ic8efeddc030f48e82ba861926121b64eca37d169
2018-11-14 15:04:31 -05:00
jenkins-bot
7a3eb1f3a6 Merge "Hard deprecate codepaths where tidy is disabled" 2018-11-13 23:54:24 +00:00
Arlo Breault
59bb8864a2 Quoted attributes don't need to be followed by a space
Further, this splits up attribute parsing from filtering.

Change-Id: Ib4e0a808a6ca2ba032873e885837233e2f2feefe
2018-11-09 16:00:18 -05:00
C. Scott Ananian
54ac31f94d Hard deprecate codepaths where tidy is disabled
Future parsers will not support the output generated with tidy disabled.

Parser tests using untidied output will also be deprecated (and
rewritten) in a follow-up patch.

No new release notes necessary since user-visible tidy configuration
was deprecated previously (in 1.32), and individual methods which had
disabled tidy during execution were individually release-noted as they
were updated.

Bug: T198214
Depends-On: I0f417f75a49dfea873e9a2f44d81796a48b9f428
Depends-On: If5c619cdd3e7f786687cfc2ca166074d9197ca11
Change-Id: I592e0e0dfef7d929f05c60ffe4d60e09725b39cc
2018-11-05 18:49:16 +00:00
Arlo Breault
d3b152b69c Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 68bfb079ab3c62d5cc79b05d496a4bc2966e9553

Change-Id: I54359f91c28ba5d622175dc1caf10a8ed8e91ad3
2018-11-05 11:57:11 -05:00
C. Scott Ananian
5dd3012d91 Don't infer parsoid-only parser tests based on presence of parsoid option.
For historical reasons, we used a complicated test to try to determine
if a test is "parsoid only" based on the presence of the string "parsoid"
in the parser test options clause.  But really test clauses should be
marked up specifically as html/php or html/parsoid, we don't need to
play hacky games any more.  Remove some unnecessary code and simplify
the test logic.

Change-Id: Ia331e7e12a75aa19aeb96601712f169f2aa75bf9
2018-11-02 16:41:40 -04:00
C. Scott Ananian
43b0016bd4 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 24b6363b9a99435479305fa98651b07e2ddb118a

Change-Id: I9090541605411af1ff3b4252b2e0902736e1ed48
2018-11-02 13:31:54 -04:00
jenkins-bot
9aedec343e Merge "Handle <nowiki> and other markup consistently in image link/alt options" 2018-11-02 01:59:01 +00:00
Max Semenik
c16704c33a Display SVGs in target language
Previously, they were always displayed in defult language unless
forced explicitly in wikitext, e.g. [[File:Foo.svg|lang=ru]].
This change adds a feature flag that would enable always trying to
display in page language.

* If enabled, Parser will pass a new parameter - 'pagelang' - to
  the media handler.
* SvgHandler uses page language when determining what language to
  render the image in.
* 'pagelang' can always be overridden by 'lang'.
* If no translation in page language is available, the default
  language (English) will be used for thumbnail URLs, to prevent
  cluttering media storage and HTTP caches with useless copies.

Performance: this requires accessing image's metadata during parsing.
My testing indicates there were no code path where this wasn't the
case already, so no performance hit is expected, however we should
still keep an eye on page save performance.

Bug: T205040
Change-Id: I348840ef405e1370cc0c17d69051bce30153c9c0
2018-10-30 16:12:11 -07:00
Fomafix
512aa4e551 Use PHP 7 '??' operator instead of if-then-else
Change-Id: Ia86f8433f30a166d38ee63d0d1745b26740767b9
2018-10-27 23:46:13 +02:00
C. Scott Ananian
ad80f0bca2 Handle <nowiki> and other markup consistently in image link/alt options
Use Parser::stripAltText() consistently to handle link and alt options
in both Parser::makeImage() and Parser::renderImageGallery().  This
ensures that link option text can use <nowiki> to escape problematic
text so that (for example) the following works:

```
[[File:Foobar.jpg|link=<nowiki>a''b''c</nowiki>|alt=<nowiki>a''b''c</nowiki>]]
<gallery>
File:Foobar.jpg|link=<nowiki>a''b''c</nowiki>|alt=<nowiki>a''b''c</nowiki>
</gallery>
```

Previously the handling of the link option in
Parser::renderImageGallery() used a bespoke `strip_tags` invocation
which didn't replace <nowiki>s, and the handling of the link option in
Parser::makeImage() didn't strip tags at all, nor did it replace
<nowiki>s.  For example, in Parser::makeImage() double quotes in
titles would be converted to embedded `<i>` tags before being passed
to Parser::parseLinkParameter(), with predictably poor results.

Tests added to confirm behavior of alt/link with HTML-escaped
entities and <nowiki>s exposed a bug in Remex: T207088.  Tests
will fail on PHP 7.0 until that is fixed.

Bug: T206940
Depends-On: Ide67bba20f771868c0e119cb2874464dcf1d758a
Change-Id: Ife4c0edaa85e0cb294c5d4c1e31d5d7d828d9df4
2018-10-22 15:26:36 +00:00
Bartosz Dziewoński
a345be42ed extraParserTests.txt: Fix typo
Change-Id: I219d22fd572abcec480d900a71d67a6cf285dd87
2018-10-19 22:22:37 +02:00
C. Scott Ananian
f7bb180fef Accept BCP 47 codes in LanguageConverter rules
Facilitate a gradual migration away from non-standard MediaWiki language
codes.  This will ensure that (a) rules can be written with standard
BCP 47 codes, and (b) rules written with existing nonstandard codes will
continue to work once these are added to
LanguageCode::$deprecatedLanguageCodeMapping.

Change-Id: I3ba96faafaf40bd47fb5919621f7035f0431a698
2018-10-16 23:58:11 -04:00
Brad Jorsch
993baa3493 ActorMigration: Remove possibility of read-both
When this was originally written, the plan was to read both the old and
new fields during the transition period, while stopping writes to them
midway through. It turns out that the WHERE conditions to do read-both
correctly are generally not handled well by the database and working
around that would require a lot of complicated code (see what's being
removed from ApiQueryUserContribs here, for example).

We can simplify things greatly by instead having it write both fields
during the transition period, reading from the old for the first part
and the new for the second part, as is being done for MCR.

Bug: T204669
Change-Id: I4764c1c7883dc1003cb12729455c8107319f70b1
Depends-On: I845f6ae462f2539ebd35cbb5f2ca8b5714e2c1fb
Depends-On: I88b31b977543fdbdf69f8c1158e77e448df94e11
2018-10-11 12:12:00 +11:00
C. Scott Ananian
1b00e01b85 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit f6c64caaf1becc5b5780c871d495a3d9f5aac7a8

Change-Id: I0d2722c100b522c68a8e35a8701d5bf7ef80dccb
2018-10-09 11:57:34 -04:00
Bartosz Dziewoński
3b00c94f98 Fix parser test failure due to changed translation
The 'sr-ec' translation of 'editsectionhint' message was changed
in dff3fa2d4b.

Change-Id: Ibb6ad22e3926406a3e8267b87ffd39ab51663e63
2018-10-09 02:01:16 +02:00
jenkins-bot
ede4b68c2b Merge "Ensure parserTests pass even if wiki has wgUsePigLatin enabled" 2018-09-20 23:04:22 +00:00
Umherirrender
a4caa4d0c6 build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
Added spaces around .
Removed empty return statement which are not required
Removed return after phpunit markTestIncomplete,
which is throwing to exit the test, no need for a return

Change-Id: I2c80b965ee52ba09949e70ea9e7adfc58a1d89ce
2018-09-16 15:51:11 +00:00
C. Scott Ananian
38d704545a Ensure parserTests pass even if wiki has wgUsePigLatin enabled
Some tests implicitly assume that English is a language with no
defined variants, which makes those tests fail if $wgUsePigLatinVariant
is true.

Change-Id: Iac5257a2fcf914a58579f06e340e8a4533befefb
2018-09-10 10:05:11 -05:00
Aryeh Gregor
ab94b63526 Improve test coverage for ApiStashEdit
Change-Id: I1b7d95e074a7f101d13398a32898b74145ab4056
2018-08-21 15:32:29 -07:00
Aryeh Gregor
1e079652e0 Introduce ContentLanguage service to replace $wgContLang
Bug: T200246
Depends-On: I31c2e20fc70ba3cbc124b9f462f4924a139dd9bd
Depends-On: I4aaf1c641ec6abef214eb96c0e4b42a67488ac00
Depends-On: I461cf2f441a4040bb15d6c4bb93ce6114c143845
Depends-On: I4b1cc4257348d1773fd2ccf045966261f801e7d0
Depends-On: I9790b7efdd484366dc36eb8880778aea1a559e5e
Change-Id: I193f5b9a95430b0a05573c361715e053e5411e32
2018-07-31 21:42:53 -07:00
Aryeh Gregor
5189333c39 MagicWordFactory to replace MagicWord static members/methods
Static members of MagicWord have been removed.

Static methods are soft-deprecated and forward to the factory.  They
will be hard-deprecated when all callers are removed from core.

MagicWord::clearCache() has been removed.  Instead, call
resetServiceForTesting( 'MagicWordFactory' ) on your MediaWikiServices
object.

Change-Id: Ie061fe90f9b9eca0cbf7e8199d9ca325c464867a
Bug: T200247
2018-07-30 21:20:43 +03:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
James D. Forrester
4b7baf11aa Follow-up 9742d569b: Replace accidental \t in i18n with a space
Change-Id: Id8ad5916b7dd59a078fb600c7998e41f1b8abd3c
2018-07-25 08:34:57 -07:00
Tim Starling
9742d569b0 parserTests: re-enable save parse and fix MCR errors
* Re-enable parse on save as requested in T159014, instead hide
  the feature behind an option.
* Add the MCR tables to the list of tables that need to be cloned. Fixes
  unconditional exception.
* Fix some undefined member variables, remove assignment to unused
  variable $this->databaseSetupDone.

Bug: T159014
Change-Id: I6be577ebcbadeb4e08079a82543d521fc2bb5948
2018-07-20 12:03:48 +10:00
Brad Jorsch
d469f53847 Parser: Remove style and script tags' content from TOC
We don't want to display the stylesheet as part of the TOC entry if
someone uses TemplateStyles in a heading.

Bug: T198618
Change-Id: I2f7316daaba0cce662b6a4702ab87322e6783655
2018-07-16 22:52:51 -04:00
Arlo Breault
acab3167f8 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit d473791ea982178af7a0fe15aff5cf8e21aaa5e8

Change-Id: Ide8a0d8df20242c9e60e40db653368ba3ef7a06c
2018-07-16 18:56:47 -04:00
Bartosz Dziewoński
6e09d07b20 Set role=button on TOC show/hide checkbox
This should give more intuitive hints in assistive technology,
identical (or similar) to the hints for the JavaScript-generated
button we had before 68527cf479.
See results of testing with Windows Narrator/VoiceOver: T195053#4428563.

Bug: T195053
Change-Id: I9358b29f56ac1e43e9c5ed00d30ce6ffdf903299
2018-07-16 18:15:48 +00:00
jenkins-bot
1360a2884a Merge "Don't armor french spaces before punctuation followed by word characters" 2018-07-13 17:22:34 +00:00
Arlo Breault
ce9f5c2546 Put <dt>/<dd>/<li> in the always-suppressing category of doBlockLevels
This is a clarification of what already happens in practice for lists
generated from wikitext syntax, since that parsing happens
simultaneously.

Parsoid, for its part, does list handling prior to paragraph wrapping,
so must make use of these definitions.

Further, this helps reduce paragraph wrapping in interstitial spacing of
lists from HTML syntax, as spec'd in the tests, though the possibility
isn't eliminated entirely.

The TOC generation code is altered to reduce the number of newlines
emitted in between list items, since those are now left intact.

Change-Id: I6888b6e8e6768b0737565b87924fefa5a06ebd18
2018-07-13 12:40:49 -04:00
Arlo Breault
5a7f860b78 <ins>/<del> elements can be phrasing or flow
The changes to the parserTests.txt highlight the differing opinions that
doBlockLevels and Remex had on whether these should be paragraph wrapped.

Since the only time they wouldn't have been was when found on a line
with other flow tags, this likely isn't a behaviour that was depended on
in practice.  And, indeed, the task describes this as a bug.

A sampling of pages from an insource:/\<(ins|del)\>/ search on wiki bears
this out.

Bug: T17491
Change-Id: I311da777a63aa3c45013f2cfc090be35a022497e
2018-07-13 11:28:10 -04:00
Arlo Breault
14f377b269 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 564b5d3a37580912793b81a021011e3e33d1219a

Change-Id: I8203797d6d6383a6a2d58d6e6f9a7d46b5c788f3
2018-07-12 11:18:54 -04:00
jenkins-bot
56d45558b1 Merge "Hide TOC with CSS instead of JavaScript" 2018-07-11 20:36:22 +00:00
Fomafix
68527cf479 Hide TOC with CSS instead of JavaScript
Changes in the behavior:
* The toggle button generate no FOUC on loading.
* On keyboard navigation the toggle key is the space key and not the
  return key.
* Animation on hide and show is missing. Maybe a new animation with CSS
  can added.
* The state of the button is not saved in a cookie.
* Self-build TOCs can not get hidden.

Browser support:
* The new implementation does not need JavaScript and therefor it works
  on browser with disabled JavaScript and on Grade C browser.
* The new implementation requires the CSS pseudo-class selector
  :checked. Therefor IE8 and lower are not supported.

Risks:
* The new implementation needs additional HTML elements. These elements
  also get cached and crawled. The elements have no content so they get
  hopefully ignored by crawler.
* The new CSS code imitates some styles (link, focus). This must kept
  up to date.
* Multiple TOCs on one page would generate the same id attribute.
  This can avoided by appending a counter or better and easier a random
  string to the id attribute.

Bug: T195053
Change-Id: I82db33d656b3795d7134a91d20ed9d93a3471086
2018-07-09 08:07:52 +02:00
Aaron Schulz
6badc74156 Fix ParserTestRunner DB table test prefix logic
Follow-up to 6cfdbdf60

Bug: T198943
Change-Id: I3c3553f2ec6b5ca0d401712e4018c7eec4d9204d
2018-07-07 09:52:43 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00