Make MSCompoundFileReader::readFile platform-agnostic
authorMáté Szabó <mszabo@wikia-inc.com>
Mon, 8 Jul 2019 16:05:22 +0000 (18:05 +0200)
committerJames D. Forrester <jforrester@wikimedia.org>
Mon, 8 Jul 2019 17:45:42 +0000 (10:45 -0700)
commit6c462836a7964fb6cb39d1153112617b0c3abf59
treeef21939214f58a7c7f61f5c0bb6d19068c61276b
parentdfec83932fd38a9086eb5a2e212889ad00f35b0e
Make MSCompoundFileReader::readFile platform-agnostic

MSCompoundFileReader::readFile uses iconv to convert information
given in UTF-16 character set with little-endian byte order to
the UTF-8 character set. The input string has no BOM and the byte order
is not explicitly given, causing iconv to try to guess the byte order
based on the host operating system. This causes the method to return
different results for the same file in different environments.

This patch explicitly provides the byte order for the input to be
converted (UTF-16LE) to ensure portability and predictability.

As part of this, move MSCompoundFileReaderTest into the unit test tree.

Bug: T225019
Change-Id: I62154897d303b28c288c3a4f2f5456bedcc81852
includes/libs/mime/MSCompoundFileReader.php
tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php [deleted file]
tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php [new file with mode: 0644]