API: Warn when input parameters are normalized
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 24 Aug 2016 18:07:43 +0000 (14:07 -0400)
committerAnomie <bjorsch@wikimedia.org>
Mon, 29 Aug 2016 15:00:45 +0000 (15:00 +0000)
commit087e25021be29e882dfc6e2e0197a531acd2f9d8
treea8ad11ccf5d463c95fc4759f98f766dd1f956f03
parent75a85b412c4adb86d3cea6986a4c0394f7a531be
API: Warn when input parameters are normalized

If a client submits data that is not NFC-normalized Unicode or that
contains C0 controls other than HT, LF, and CR, it gets normalized before
the API ever sees it. Which can lead to difficult-to-handle bugs when,
for example, a title is subject to normalization so the client can't
find the specific title it submitted anywhere in the response (T139130).

This patch does two things:
* Detects when normalization was applied to an input value (at the
  MediaWiki level, anyway; if PHP or earlier does it we're just out of
  luck) and add a warning to that effect.
* For ApiPageSet's 'titles' parameter, split into the individual titles
  and add them to the 'normalized' list in the response. This requires
  encoding the pre-normalized strings to avoid ApiResult's own
  normalization.

Bug: T29849
Bug: T144071
Change-Id: I215fd3edd7a5e1b45292e60768bf6dd5ad7f34de
RELEASE-NOTES-1.28
includes/api/ApiBase.php
includes/api/ApiPageSet.php
includes/api/i18n/en.json
tests/phpunit/includes/api/ApiBaseTest.php
tests/phpunit/includes/api/ApiPageSetTest.php
tests/phpunit/includes/api/query/ApiQueryTest.php