Skip to content

Commit baa890c

Browse files
committed
Use MBString functions for 8bit data read
Prevents issues with MBString overrides of standard PHP functions.
1 parent 219801d commit baa890c

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/FontLib/EOT/File.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public function read($n) {
7474
}
7575

7676
$string = fread($this->f, $n);
77-
$chunks = str_split($string, 2);
78-
$chunks = array_map("strrev", $chunks);
77+
$chunks = mb_str_split($string, 2, '8bit');
7978

8079
return implode("", $chunks);
8180
}

src/FontLib/Table/DirectoryEntry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ class DirectoryEntry extends BinaryStream {
3737
protected $origF;
3838

3939
static function computeChecksum($data) {
40-
$len = strlen($data);
40+
$len = mb_strlen($data, '8bit');
4141
$mod = $len % 4;
4242

4343
if ($mod) {
4444
$data = str_pad($data, $len + (4 - $mod), "\0");
4545
}
4646

47-
$len = strlen($data);
47+
$len = mb_strlen($data, '8bit');
4848

4949
$hi = 0x0000;
5050
$lo = 0x0000;

src/FontLib/TrueType/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function parse() {
124124
}
125125

126126
function utf8toUnicode($str) {
127-
$len = strlen($str);
127+
$len = mb_strlen($str, '8bit');
128128
$out = array();
129129

130130
for ($i = 0; $i < $len; $i++) {

src/FontLib/WOFF/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function load($file) {
5050
}
5151

5252
// Prepare data ...
53-
$length = strlen($data);
53+
$length = mb_strlen($data, '8bit');
5454
$entry->length = $entry->origLength = $length;
5555
$entry->offset = $dataOffset;
5656

0 commit comments

Comments
 (0)