Ticket #19922: 19922.patch
File 19922.patch, 1.2 KB (added by , 13 years ago) |
---|
-
class-http.php
1540 1540 if ( empty( $this->name ) || empty( $this->value ) ) 1541 1541 return ''; 1542 1542 1543 return $this->name . '=' . urlencode( $this->value );1543 return $this->name . '=' . $this->encodeString( $this->value ); 1544 1544 } 1545 1546 /** 1547 * URL encode non-printable characters only 1548 * 1549 * @link http://stackoverflow.com/a/1969339 1550 * 1551 * @param string $str 1552 * @return string 1553 */ 1554 public function encodeString( $str ) { 1555 $chars = preg_split( '//', $str, -1, PREG_SPLIT_NO_EMPTY ); 1556 return implode( '', array_map( array( $this, 'encodeChar' ), $chars ) ); 1557 } 1545 1558 1559 /** 1560 * Encode only non-printable chars 1561 * @param string $char 1562 * @return string 1563 */ 1564 public function encodeChar( $char ) { 1565 if ( ctype_print( $char ) && !in_array( $char, array( '=', ';', ' ', '%', '+' ) ) ) 1566 return $char; 1567 return urlencode( $char ); 1568 } 1569 1546 1570 /** 1547 1571 * Retrieve cookie header for usage in the rest of the WordPress HTTP API. 1548 1572 *