diff --git a/src/Runtime/Exception/MappingFailedException.php b/src/Runtime/Exception/MappingFailedException.php index 1189f9e..e7dd40c 100644 --- a/src/Runtime/Exception/MappingFailedException.php +++ b/src/Runtime/Exception/MappingFailedException.php @@ -23,11 +23,12 @@ use function substr; use const JSON_PRESERVE_ZERO_FRACTION; use const JSON_THROW_ON_ERROR; +use const JSON_UNESCAPED_SLASHES; class MappingFailedException extends RuntimeException { - private const JSON_ENCODE_OPTIONS = JSON_PRESERVE_ZERO_FRACTION | JSON_THROW_ON_ERROR; + private const JSON_ENCODE_OPTIONS = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR; private const MAX_STRING_LENGTH = 40; /** diff --git a/tests/Runtime/Exception/MappingFailedExceptionTest.php b/tests/Runtime/Exception/MappingFailedExceptionTest.php index e0a7be9..646837a 100644 --- a/tests/Runtime/Exception/MappingFailedExceptionTest.php +++ b/tests/Runtime/Exception/MappingFailedExceptionTest.php @@ -71,6 +71,11 @@ public static function provideMessagesData(): iterable 'Failed to map data at path /foo: Expected int, got "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (truncated)', ]; + yield 'string with slash' => [ + MappingFailedException::incorrectValue('foo/bar', ['foo'], 'int'), + 'Failed to map data at path /foo: Expected int, got "foo/bar"', + ]; + yield 'string with control characters' => [ MappingFailedException::incorrectValue("foo\x00bar", ['foo'], 'int'), 'Failed to map data at path /foo: Expected int, got string',