8000 DOMXPath::quote(string $str): string by divinity76 · Pull Request #13456 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

DOMXPath::quote(string $str): string #13456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
safe_alloc + null terminated
  • Loading branch information
divinity76 committed Feb 22, 2024
commit 7c478a19bce51a474b10d7d75e0e1a02b6212e14
6 changes: 4 additions & 2 deletions ext/dom/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,16 +454,18 @@ PHP_METHOD(DOMXPath, quote) {
RETURN_THROWS();
}
if (memchr(input, '\'', input_len) == NULL) {
zend_string *const output = zend_string_alloc(input_len + 2, 0);
zend_string *const output = zend_string_safe_alloc(1, input_len, 2, false);
output->val[0] = '\'';
memcpy(output->val + 1, input, input_len);
output->val[input_len + 1] = '\'';
output->val[input_len + 2] = '\0';
RETURN_STR(output);
} else if (memchr(input, '"', input_len) == NULL) {
zend_string *const output = zend_string_alloc(input_len + 2, 0);
zend_string *const output = zend_string_safe_alloc(1, input_len, 2, false);
output->val[0] = '"';
memcpy(output->val + 1, input, input_len);
output->val[input_len + 1] = '"';
output->val[input_len + 2] = '\0';
RETURN_STR(output);
} else {
smart_str output = {0};
Expand Down
0