Repository navigation
Commit c1db7a4
committed
ext/standard: Return the input of htmlspecialchars() when nothing needs encoding
htmlspecialchars() allocated a buffer of twice the input and decoded it
character by character, even when the result was the input itself.
The input is now scanned first for the characters that need encoding and
for invalid multi-byte sequences, with SSE2 on 16-byte blocks. When there
is none, the input string is returned, as html_entity_decode() and
htmlspecialchars_decode() already do since 68dc754. Otherwise, encoding
starts after the part that was scanned.
The @refcount 1 annotations of htmlspecialchars() and htmlentities() are
removed since they can now return their argument.1 parent c13fabf commit c1db7a4
8 files changed
Lines changed: 308 additions & 95 deletions
File tree
- Zend/Optimizer
- ext/standard
- tests/strings
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
467 | | - | |
468 | 466 | | |
469 | 467 | | |
470 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2267 | 2267 | | |
2268 | 2268 | | |
2269 | 2269 | | |
2270 | | - | |
2271 | 2270 | | |
2272 | 2271 | | |
2273 | 2272 | | |
2274 | 2273 | | |
2275 | 2274 | | |
2276 | 2275 | | |
2277 | | - | |
2278 | 2276 | | |
2279 | 2277 | | |
2280 | 2278 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments