File tree Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1
1
# API Response Builder for Laravel 5 #
2
2
3
-
4
3
See [ compatibility docs] ( docs/compatibility.md ) for details about backward compatibility!
5
4
6
-
7
5
## CHANGE LOG ##
8
6
9
7
* @dev
8
+ * [ RB-42] Default value of ` encoding_options ` include ` JSON_UNESCAPED_UNICODE ` to prevent unicode escaping
10
9
* [ RB-41] Updated documentation
11
10
12
11
* v3.1.0 (2017-02-28)
13
- * [ RB-38] Added ` encoding-options ` to control data-to-json conversion.
12
+ * [ RB-38] Added ` encoding_options ` to control data-to-json conversion.
14
13
* [ RB-38] Added optional encoding options args to all methods accepting ` data ` argument
15
14
* [ RB-34] Added option to control ExceptionHandeler behavior on debug builds
16
15
* ExceptionHandler's debug is now added as ` debug ` node to make it more clear where it comes from
@@ -109,3 +108,4 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
109
108
110
109
* v1.0.0 (2016-04-11)
111
110
* Initial public release
111
+
Original file line number Diff line number Diff line change 94
94
| to be returned escaped, which while technically correct (ant theoretically
95
95
| transparent) might not be desired effects.
96
96
|
97
- | To prevent escaping, add JSON_UNESCAPED_UNICODE:
97
+ | To prevent escaping, add JSON_UNESCAPED_UNICODE (default since v3.2) :
98
98
| JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_AMP|JSON_HEX_QUOT|JSON_UNESCAPED_UNICODE
99
99
|
100
- | Default value:
100
+ | Laravel's value:
101
101
| JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_AMP|JSON_HEX_QUOT
102
102
|
103
103
| See http://php.net/manual/en/function.json-encode.php for details
104
104
|
105
105
*/
106
- 'encoding_options ' => JSON_HEX_TAG |JSON_HEX_APOS |JSON_HEX_AMP |JSON_HEX_QUOT ,
106
+ 'encoding_options ' => JSON_HEX_TAG |JSON_HEX_APOS |JSON_HEX_AMP |JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE ,
107
107
108
108
109
109
/*
Original file line number Diff line number Diff line change @@ -40,11 +40,11 @@ class ResponseBuilder
40
40
/**
41
41
* Default JSON encoding options
42
42
*
43
- * 15 = JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_AMP|JSON_HEX_QUOT
43
+ * 271 = JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_AMP|JSON_HEX_QUOT|JSON_UNESCAPED_UNICODE
44
44
*
45
45
* This must be as int due to const limits in PHP disallowing expressions.
46
46
*/
47
- const DEFAULT_ENCODING_OPTIONS = 15 ;
47
+ const DEFAULT_ENCODING_OPTIONS = 271 ;
48
48
49
49
/**
50
50
* Reads and validates "classes" config mapping
Original file line number Diff line number Diff line change @@ -69,13 +69,14 @@ public function testMake_InvalidEncodingOptions()
69
69
}
70
70
71
71
/**
72
- * Tests if JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_AMP|JSON_HEX_QUOT matches const value of DEFAULT_ENODING_OPTIONS
72
+ * Tests if dist's config detaults matches ResponseBuilder:: DEFAULT_ENODING_OPTIONS
73
73
*
74
74
* @return void
75
75
*/
76
76
public function testDefaultEncodingOptionValue ()
77
77
{
78
- $ this ->assertEquals (JSON_HEX_TAG |JSON_HEX_APOS |JSON_HEX_AMP |JSON_HEX_QUOT , ResponseBuilder::DEFAULT_ENCODING_OPTIONS );
78
+ $ config_defaults = \Config::get ('response_builder.encoding_options ' );
79
+ $ this ->assertEquals ($ config_defaults , ResponseBuilder::DEFAULT_ENCODING_OPTIONS );
79
80
}
80
81
81
82
/**
@@ -87,7 +88,7 @@ public function testMake_DefaultEncodingOptions()
87
88
{
88
89
// source data
89
90
$ test_string = 'ąćę ' ;
90
- $ test_string_escaped = $ this ->escape8 ($ test_string );
91
+ // $test_string_escaped = $this->escape8($test_string);
91
92
$ data = ['test ' => $ test_string ];
92
93
93
94
// fallback defaults in action
You can’t perform that action at this time.
0 commit comments