Skip to content

Commit d760ab9

Browse files
authored
Merge pull request #155 from edsrzf/rm-utf8-encode
Remove usage of deprecated utf8_encode function
2 parents a479ce6 + 13a775d commit d760ab9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Raygun4php/RaygunRequestMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct()
4242
$utf8_convert_server = function ($value) use (&$utf8_convert_server) {
4343
return is_array($value) ?
4444
array_map($utf8_convert_server, $value) :
45-
iconv('UTF-8', 'UTF-8', utf8_encode($value));
45+
iconv('ISO-8859-1', 'UTF-8', $value);
4646
};
4747

4848
$this->Form = array_map($utf8_convert, $_POST);

tests/RaygunClientTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,19 @@ public function testValidateMessageJsonInTransportObj()
277277
$schemaValidator->validate($data, $this->jsonSchema);
278278
$this->assertTrue($schemaValidator->isValid());
279279
}
280+
281+
/**
282+
* @backupGlobals enabled
283+
*/
284+
public function testServerUtf8Conversion()
285+
{
286+
$_SERVER = [
287+
'a' => 'hello',
288+
'b' => "\xc0\xde",
289+
];
290+
$requestMessage = new RaygunRequestMessage();
291+
292+
$this->assertSame('hello', $requestMessage->Data['a']);
293+
$this->assertSame('ÀÞ', $requestMessage->Data['b']);
294+
}
280295
}

0 commit comments

Comments
 (0)