Page MenuHomePhabricator

PostgreSQL validates UTF8 feilds, which makes the use of pack in Math.php unacceptable.
Closed, ResolvedPublic

Description

Author: pomac

Description:
I thought i had put up a bug about this somewhere, including a patch, but i
might have been on sf...

The use of pack in Math.php breaks because PostgreSQL, quite correctly,
validates it's utf8 input. Once upon a time i had a proper patch for this, but
now i only have a 1.9.2 diff against 1.9.3...

Anyways, to give a understanding of the changes that should be made:
@@ -153,9 +152,9 @@

    1. Now save it back to the DB: if ( !wfReadOnly() ) {
  • $outmd5_sql = $this->hash;

+ $outmd5_sql = pack('H32', $this->hash);

  • $md5_sql = $this->md5;

+ $md5_sql = pack('H32', $this->md5); # Binary
packed, not hex

$dbw =& wfGetDB( DB_MASTER );
$dbw->replace( 'math', array( 'math_inputhash' ),

@@ -189,12 +188,13 @@

$dbr =& wfGetDB( DB_SLAVE );
$rpage = $dbr->selectRow( 'math',
        array(

'math_outputhash','math_html_conservativeness','math_html','math_mathml' ),

  • array( 'math_inputhash' => $this->md5), $fname

+ array( 'math_inputhash' => pack("H32", $this->md5)), #
Binary packed, not hex
+ $fname

);
 
if( $rpage !== false ) {
        # Tailing 0x20s can get dropped by the database, add it

back on if necessary:

  • $xhash = $rpage->math_outputhash;

+ $xhash = unpack( 'H32md5', $rpage->math_outputhash . "

" );
          $this->hash = $xhash ['md5'];
 
          $this->conservativeness =

$rpage->math_html_conservativeness;

I do, however assume that $fname has been added since i changed my version...


Version: unspecified
Severity: normal
OS: Linux
Platform: PC

Details

Reference
bz9546

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:36 PM
bzimport set Reference to bz9546.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

*** This bug has been marked as a duplicate of 8716 ***