Commit graph

32 commits

Author SHA1 Message Date
Siebrand Mazeland
d5df012a13 Pass phpcs-strict on some test files (3/x)
Change-Id: I44172b512cd9b6c43806dad697e449bf06897305
2014-04-24 18:51:39 +02:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
jenkins-bot
bcb8fee4a9 Merge "Put the HTML attribute whitelist closer to HTML5" 2013-11-02 14:07:07 +00:00
addshore
fb16eb2abe Add more @covers tags and test cleanup
Other cleanup includes
 - Adding method scopes
 - Fixing php comments
 - Adding todos

Change-Id: I0a231008e6a59110ffcab6af1bd8c4d3ee13f21d
2013-10-22 08:59:42 +00:00
entlinkt
3062f70742 Put the HTML attribute whitelist closer to HTML5
* Add the global attributes to <bdo> and <q> and add "cite" to <q>. This
  is to make these elements actually usable: <bdo> needs a "dir" attribute
  to be useful for anything, and the whole point of <q> compared to
  hard-coded quotation marks is its support for the "lang" and "cite"
  attributes.
* Drop the "align" attribute from <span> because it was never standards-
  compliant and does not work in browsers either, unless one constructs
  such unlikely things as <span align="center" style="display:block;">.
* Drop the obsolete "char" and "charoff" attributes from <tr>, <td>, <th>.
  These have not been implemented in browsers anyway.
* Drop the obsolete presentational attributes "align", "valign" and "width"
  from <colgroup>, <col>, <thead>, <tfoot> and <tbody>. These elements are
  currently not accepted in wikitext anyway, but removing these attributes
  from the whitelist ensures that they are not accidentally enabled in the
  future.
* Drop the obsolete presentational attributes "noshade" and "size" from <hr>.
  They have been overridden by skin-specific CSS for a long time anyway.
* Allow all global attributes on <br> and <wbr>. Not allowing "dir" and "lang"
  on <br> was a restriction in HTML 4.01, presumably copied to <wbr>, that
  has been lifted in HTML5. Allowing these may not be particularly useful,
  but simplifies the code.

Bug: 55582
Change-Id: I1c3289ef51a449a7837af28d9906701534175896
2013-10-12 13:32:32 +02:00
MatmaRex
267b582e16 displaytitle: reject some CSS if $wgRestrictDisplayTitle set
$wgRestrictDisplayTitle is intended to make it possible to simply
copy-and-paste the title text even if it requires some styling like
subscript or superscript. Using a <span style="display: none;" />
broke that expectation, as the text hidden in such way becomes
completely invisible and unselectable. This patch rejects such styles.

Also disallowed 'user-select' and 'visibility', since they both
prevent the user from selecting and/or copying the text as well.

Minor changes in Sanitizer:
* checkCss() was made to pass through values which consist of nothing
  but a single comment, to allow this rejection to display some sort
  of a notification to the user.
* encodeTagAttributes() was added as a counterpart to
  decodeTagAttributes(), pulling some code out of fixTagAttributes().

Bug: 26547
Change-Id: Ie162535b6bcbebce4ee69f6dcc1957ccccc3c672
2013-05-24 15:05:37 +02:00
Daniel Friesen
97caae596d Drop support for XHTML 1.0
* $wgHtml5 = false; is now ignored completely.
* $wgDocType and $wgDTD have been removed.
* $wgXhtmlDefaultNamespace is now ignored.
* XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules).
* For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set
  in Setup.php but depending on them is deprecated.

Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
2013-05-15 23:09:25 -07:00
Daniel Friesen
22fe71315b (bug 41545) Allow kbd, samp, and var to be nested.
HTML5 has various semantics that allow -- or rather require --
<kbd> and <samp> and even <var> to be nested.

eg: <kbd><kbd>Shift</kbd>+<kbd>F3</kbd></kbd>
eg: <var>x<sub><var>i</var></sub></var>, <var>y<sub><var>i</var></sub></var>

This fixes the sanitizer to permit their nesting and adds test cases to ensure that some
of HTML5's special semantics are permitted by our sanitizer and not broken.

Change-Id: I6ad64e6eb4c9b5bdc15be513f55c58f6717c3939
2013-05-13 19:15:59 -07:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00: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
jenkins-bot
aeae4fedda Merge "Support WAI-ARIA's role="presentation" inside of WikiText." 2013-02-15 16:56:00 +00:00
Siebrand Mazeland
7a24666935 Update formatting
2 of n.

Change-Id: I5406673e99ed53e4e330ed47f022a17177544daa
2013-02-14 12:36:35 +01:00
Daniel Friesen
ea1a1cd5db Support WAI-ARIA's role="presentation" inside of WikiText.
- role="presentation" is the standard way to mark some element as presentational for assistive technologies, etc...
  Such as presentational tables. Something we have a lot of and need the ability to mark as presentational.
- Other ARIA roles need more thought so for now they are not supported.

Change-Id: I426ea04a8bc48181a71a308753525f3964201748
2013-02-12 16:40:01 -08:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Antoine Musso
8099133ab3 testDecodeTagAttributes now use a data provider
We had a huge pile of assertEquals in a single test function, this patch
convert the mess in a nicer dataprovider.

The parameters passed to assertEquals() were mixed up, the expected
values should be passed as the first argument, I thus exchange the first
two parameters in each case.

Change-Id: Ib74804a7aa84a1e59fffb8c85abbf0b95995d897
2013-01-18 13:47:38 +00:00
Antoine Musso
2b3714db26 normalize sanitizerTest and add coverage tips
* @cover let us mention which function the test is using, help out when
  building coverage report to make sure we only record traces for that
  function.
* Normalized test functions so they look alike and make use of an
  optional message.

Change-Id: I3e431b28e377f2ca21d06300537f63b2df4a3a99
2013-01-18 13:43:39 +00:00
umherirrender
45dea98358 Fix SanitizerTest for wikis with wgUseTidy = true;
testRemovehtmltagsOnHtml5Tags needs wgUseTidy = false;

3) SanitizerTest::testRemovehtmltagsOnHtml5Tags with data set #2
('time', false)

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<time></time>
-'
+'<time>'

Change-Id: Ib7e156293e2efae053b055e40393e442719eb5bd
2012-12-09 11:03:03 +01:00
Platonides
6e20a8c245 Fix $wgHtml5 case. Follow-up c35304 (0473c33)
Change-Id: Ie5916a5fbb64873adb0ed8a6fdd0aca666c7ebf1
2012-11-27 18:47:30 +01:00
Platonides
0473c33ecb $wgHTML5 is a different variable than $wgHtml5 and the right name is the later.
Change-Id: Idfc2e2b61a791a2d9d6a33cbffe2fc12054e22d8
2012-11-26 22:34:40 +01:00
Timo Tijhof
5f41c8ba87 (bug 40632) Remove CleanupPresentationalAttributes feature
Removed $wgCleanupPresentationalAttributes, the associated
code it toggles and references to those in src and tests.

Also fixes bug 40329.

This was originally introduced in r94465 (released in REL1_19) but
disabled by default. Then enabled in r98053, after which several
bugs were filed and eventually the decision was made to remove
this feature.

Removed obsolete release-note entry, as this is to be backported
to REL1_20.

Change-Id: I4e86305520a3b22ef88381caab55d24abac932e3
2012-11-19 22:09:17 +01:00
Daniel Friesen
e47082d6c2 (bug 39067) Add support for HTML5 <mark> element.
* whitelist <mark> in tidy and sanitizer
* provides a default styling for mark elements

Change-Id: I23fc2fc558ff0590be04771ef1e75fcfdf240aac
2012-11-19 09:22:48 +01:00
Daniel Friesen
d9a422f0d1 Preemptively add image-set to our sanitizer.
WebKit's -webkit-image-set() requires a url() to work however css4-images'
version of image-set permits strings such that image-set( 'asdf.png' 1x ) would be permitted
and would bypass our filters.

Change-Id: I366d04807f66df449f791a5e8e2cb58768124a9a
2012-10-29 08:32:53 +00:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Daniel Friesen
3842f9a262 Preemptively add css3's image() to our css sanitizer.
- Adding this now even though no browser supports it so that when one does it doesn't become a way to bypass our url() filter.
- Including missing tests for all of our insecure input filters.
- Also make sure that vendor prefixed versions like -webkit-image() are caught because most browsers are probably going to go and implement a vendor prefixed version first.

Change-Id: If73aa98b8accdb7621b0e4ff0615b61d530fa547
2012-09-26 05:24:16 +00:00
Antoine Musso
218d50c0c3 (bug 40306) Only convert align to float for table.
Align should be converted to text-align for all the elements specified
in $presentationalAttribs mapping. Table however is an exception, it
applies to alignment of the block (instead of the content).

Follow up I108cbd10 / 27a4d74bd7.

Change-Id: Iee17d4ef1a6a9b46d88a330cfc9179bccfe93247
2012-09-18 14:44:50 +02:00
Max Semenik
27a4d74bd7 (bug 36495) Sanitizer: Convert align to margin/float outside tables.
Change-Id: I108cbd100cff6bade011b14d74b5bca82f2a1e5f
2012-07-03 08:54:46 +02:00
Antoine Musso
1b39c964ab Test handling of escaped CSS comments
r85856 fixed a CSS injection issue but lacked testing. This
test verify we properly strip out CSS comments even when the
token delimiter '/*' is backslash-escaped : \2f\2a
2011-10-24 08:39:58 +00:00
Daniel Friesen
453528cc4b Followup r94465 and r94465; Add phpunit tests for Sanitizer::fixDeprecatedAttributes and fix bugs related to clear="all" and mixed/uppercase attributes and values. 2011-09-25 04:08:23 +00:00
Platonides
b856f6605b (Bug 27539) Allow attributes beginning with a digit in wiktext tag parameters.
Its removal in r70849 breaks ProofreadPage extension.
Restricted r82475 relaxation to just numbers.
Added tests.

This only affects wikitext (tag hooks).
MW_ATTRIBS_REGEX is only used through decodeTagAttributes() calls.
fixTagAttributes() calls decodeTagAttributes(), and would be nastier to 
fix, since it is called with HTML parameters (eg. by removeHTMLtags)
but such incorrect parameters grabbed would be removed by validateTagAttributes()
2011-02-19 20:16:54 +00:00
Chad Horohoe
447529064b * verbose and color default output from phpunit
* Make a bunch of tests subclass MediaWikiTestCase
* Parser tests and ResourceLoaderTest can't subclass it yet due to various issues
2010-12-28 18:17:16 +00:00
Chad Horohoe
23f69f10ed Per wikitech-l discussion: Move tests from maintenance/tests/ to tests/. They're not strictly maintenance scripts, and some people want to do a selective checkout that doesn't include the tests. There's still debate on whether we should include these in the release downloads, but we had a pretty firm consensus to move this. 2010-12-14 16:26:35 +00:00