mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Remove UTF8 BMP unit test and replace it with a general UTF8 test
Summary: Ref T1191. After utf8mb4 conversion, these tests no longer pass because MySQL allows emoji and gclefs and such. We could keep these tests running by keeping a `ut8f_bin` table around somewhere, but we have no other use cases for it and it does not seem worth the added complexity. All these BMP-only codepaths are on the way out. Update the `%s` / `%B` test to make sure it's rejecting invalid byte sequences, which are still not permitted. Test Plan: Tests now pass. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10621
This commit is contained in:
parent
8fa8415c07
commit
410c2ecbfd
1 changed files with 4 additions and 53 deletions
|
@ -50,69 +50,20 @@ final class PhabricatorInfrastructureTestCase extends PhabricatorTestCase {
|
|||
'In test cases, all applications should default to installed.');
|
||||
}
|
||||
|
||||
public function testMySQLAgreesWithUsAboutBMP() {
|
||||
// Build a string with every BMP character in it, then insert it into MySQL
|
||||
// and read it back. We expect to get the same string out that we put in,
|
||||
// demonstrating that strings which pass our BMP checks are also valid in
|
||||
// MySQL and no silent data truncation will occur.
|
||||
|
||||
$buf = '';
|
||||
|
||||
for ($ii = 0x01; $ii <= 0x7F; $ii++) {
|
||||
$buf .= chr($ii);
|
||||
}
|
||||
|
||||
for ($ii = 0xC2; $ii <= 0xDF; $ii++) {
|
||||
for ($jj = 0x80; $jj <= 0xBF; $jj++) {
|
||||
$buf .= chr($ii).chr($jj);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This is \xE0\xA0\xZZ.
|
||||
for ($ii = 0xE0; $ii <= 0xE0; $ii++) {
|
||||
for ($jj = 0xA0; $jj <= 0xBF; $jj++) {
|
||||
for ($kk = 0x80; $kk <= 0xBF; $kk++) {
|
||||
$buf .= chr($ii).chr($jj).chr($kk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This is \xE1\xZZ\xZZ through \xEF\xZZ\xZZ.
|
||||
for ($ii = 0xE1; $ii <= 0xEF; $ii++) {
|
||||
for ($jj = 0x80; $jj <= 0xBF; $jj++) {
|
||||
for ($kk = 0x80; $kk <= 0xBF; $kk++) {
|
||||
$buf .= chr($ii).chr($jj).chr($kk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEqual(194431, strlen($buf));
|
||||
$this->assertTrue(phutil_is_utf8_with_only_bmp_characters($buf));
|
||||
|
||||
$write = id(new HarbormasterScratchTable())
|
||||
->setData('all.utf8.bmp')
|
||||
->setBigData($buf)
|
||||
->save();
|
||||
|
||||
$read = id(new HarbormasterScratchTable())->load($write->getID());
|
||||
|
||||
$this->assertEqual($buf, $read->getBigData());
|
||||
}
|
||||
|
||||
public function testRejectMySQLBMPQueries() {
|
||||
public function testRejectMySQLNonUTF8Queries() {
|
||||
$table = new HarbormasterScratchTable();
|
||||
$conn_r = $table->establishConnection('w');
|
||||
|
||||
$snowman = "\xE2\x98\x83";
|
||||
$gclef = "\xF0\x9D\x84\x9E";
|
||||
$invalid = "\xE6\x9D";
|
||||
|
||||
qsprintf($conn_r, 'SELECT %B', $snowman);
|
||||
qsprintf($conn_r, 'SELECT %s', $snowman);
|
||||
qsprintf($conn_r, 'SELECT %B', $gclef);
|
||||
qsprintf($conn_r, 'SELECT %B', $invalid);
|
||||
|
||||
$caught = null;
|
||||
try {
|
||||
qsprintf($conn_r, 'SELECT %s', $gclef);
|
||||
qsprintf($conn_r, 'SELECT %s', $invalid);
|
||||
} catch (AphrontCharacterSetQueryException $ex) {
|
||||
$caught = $ex;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue