@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+4 -53
+4 -53
src/__tests__/PhabricatorInfrastructureTestCase.php
··· 50 50 'In test cases, all applications should default to installed.'); 51 51 } 52 52 53 - public function testMySQLAgreesWithUsAboutBMP() { 54 - // Build a string with every BMP character in it, then insert it into MySQL 55 - // and read it back. We expect to get the same string out that we put in, 56 - // demonstrating that strings which pass our BMP checks are also valid in 57 - // MySQL and no silent data truncation will occur. 58 - 59 - $buf = ''; 60 - 61 - for ($ii = 0x01; $ii <= 0x7F; $ii++) { 62 - $buf .= chr($ii); 63 - } 64 - 65 - for ($ii = 0xC2; $ii <= 0xDF; $ii++) { 66 - for ($jj = 0x80; $jj <= 0xBF; $jj++) { 67 - $buf .= chr($ii).chr($jj); 68 - } 69 - } 70 - 71 - // NOTE: This is \xE0\xA0\xZZ. 72 - for ($ii = 0xE0; $ii <= 0xE0; $ii++) { 73 - for ($jj = 0xA0; $jj <= 0xBF; $jj++) { 74 - for ($kk = 0x80; $kk <= 0xBF; $kk++) { 75 - $buf .= chr($ii).chr($jj).chr($kk); 76 - } 77 - } 78 - } 79 - 80 - // NOTE: This is \xE1\xZZ\xZZ through \xEF\xZZ\xZZ. 81 - for ($ii = 0xE1; $ii <= 0xEF; $ii++) { 82 - for ($jj = 0x80; $jj <= 0xBF; $jj++) { 83 - for ($kk = 0x80; $kk <= 0xBF; $kk++) { 84 - $buf .= chr($ii).chr($jj).chr($kk); 85 - } 86 - } 87 - } 88 - 89 - $this->assertEqual(194431, strlen($buf)); 90 - $this->assertTrue(phutil_is_utf8_with_only_bmp_characters($buf)); 91 - 92 - $write = id(new HarbormasterScratchTable()) 93 - ->setData('all.utf8.bmp') 94 - ->setBigData($buf) 95 - ->save(); 96 - 97 - $read = id(new HarbormasterScratchTable())->load($write->getID()); 98 - 99 - $this->assertEqual($buf, $read->getBigData()); 100 - } 101 - 102 - public function testRejectMySQLBMPQueries() { 53 + public function testRejectMySQLNonUTF8Queries() { 103 54 $table = new HarbormasterScratchTable(); 104 55 $conn_r = $table->establishConnection('w'); 105 56 106 57 $snowman = "\xE2\x98\x83"; 107 - $gclef = "\xF0\x9D\x84\x9E"; 58 + $invalid = "\xE6\x9D"; 108 59 109 60 qsprintf($conn_r, 'SELECT %B', $snowman); 110 61 qsprintf($conn_r, 'SELECT %s', $snowman); 111 - qsprintf($conn_r, 'SELECT %B', $gclef); 62 + qsprintf($conn_r, 'SELECT %B', $invalid); 112 63 113 64 $caught = null; 114 65 try { 115 - qsprintf($conn_r, 'SELECT %s', $gclef); 66 + qsprintf($conn_r, 'SELECT %s', $invalid); 116 67 } catch (AphrontCharacterSetQueryException $ex) { 117 68 $caught = $ex; 118 69 }