Commit 9072a51
committed
Match unserialize() permissiveness on scoped-mode property names
In scoped mode, the pre-v0.4.0 hot-path validation rejected any property
name that wasn't a string, contained a NUL byte, or looked like a mangled
key, with a ValueError. That was stricter than what `unserialize()` does
when it encounters the same shapes in an `O:…` payload:
- Integer keys: `unserialize()` coerces to string on dynamic property
access (PHP's engine rule). The ext now iterates via ZEND_HASH_FOREACH_KEY_VAL
and synthesises the string via `zend_long_to_str`.
- NUL-in-middle names: `unserialize()` stores them as-is on the dynamic
property table. The ext drops the upfront `memchr` check on the stdClass
write path and the dynamic-fallback write path, letting the engine store
the raw name.
- NUL-prefix names: the engine native `Error` ("Cannot access property
starting with \0") already surfaces from `zend_std_write_property` /
`zend_hash_update`. No need for a pre-check.
DEEPCLONE_HYDRATE_MANGLED_VARS mode is unchanged — it still parses and
validates mangled keys as before (that's the entire point of the flag).
Besides the semantic alignment, this saves a hot-path validation per
written property — ~18 ns per prop in the polyfill, cheap in the ext but
the polyfill side is the real win.1 parent 4f47a1b commit 9072a51
3 files changed
Lines changed: 43 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3218 | 3218 | | |
3219 | 3219 | | |
3220 | 3220 | | |
| 3221 | + | |
3221 | 3222 | | |
3222 | 3223 | | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
3226 | | - | |
3227 | | - | |
3228 | | - | |
3229 | | - | |
3230 | | - | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
3231 | 3231 | | |
3232 | 3232 | | |
3233 | 3233 | | |
| |||
3292 | 3292 | | |
3293 | 3293 | | |
3294 | 3294 | | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
3298 | | - | |
3299 | | - | |
3300 | | - | |
3301 | | - | |
3302 | | - | |
3303 | | - | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
3304 | 3298 | | |
3305 | 3299 | | |
3306 | 3300 | | |
| |||
3317 | 3311 | | |
3318 | 3312 | | |
3319 | 3313 | | |
| 3314 | + | |
3320 | 3315 | | |
3321 | 3316 | | |
3322 | 3317 | | |
3323 | 3318 | | |
3324 | 3319 | | |
3325 | 3320 | | |
3326 | | - | |
3327 | | - | |
3328 | | - | |
3329 | | - | |
3330 | | - | |
3331 | | - | |
3332 | | - | |
3333 | | - | |
3334 | | - | |
3335 | | - | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
3336 | 3324 | | |
3337 | 3325 | | |
| 3326 | + | |
3338 | 3327 | | |
3339 | 3328 | | |
3340 | 3329 | | |
3341 | 3330 | | |
3342 | 3331 | | |
3343 | 3332 | | |
3344 | 3333 | | |
| 3334 | + | |
3345 | 3335 | | |
3346 | 3336 | | |
3347 | 3337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
277 | 275 | | |
278 | | - | |
| 276 | + | |
279 | 277 | | |
280 | 278 | | |
281 | 279 | | |
282 | 280 | | |
283 | 281 | | |
284 | 282 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
291 | 287 | | |
292 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
293 | 291 | | |
294 | 292 | | |
295 | | - | |
296 | | - | |
| 293 | + | |
| 294 | + | |
297 | 295 | | |
298 | 296 | | |
299 | 297 | | |
| |||
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
385 | | - | |
386 | 383 | | |
0 commit comments