Skip to content

Revert "Port XML_GetCurrentByteIndex to public APIs" #18407

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
17 changes: 2 additions & 15 deletions ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,21 +709,8 @@ XML_GetCurrentColumnNumber(XML_Parser parser)
PHP_XML_API int
XML_GetCurrentByteIndex(XML_Parser parser)
{
/* We have to temporarily disable the encoder to satisfy the note from the manual:
* "This function returns byte index according to UTF-8 encoded text disregarding if input is in another encoding."
* Although that should probably be corrected at one point? (TODO) */
xmlCharEncodingHandlerPtr encoder = NULL;
xmlParserInputPtr input = parser->parser->input;
if (input->buf) {
encoder = input->buf->encoder;
input->buf->encoder = NULL;
}
long result = xmlByteConsumed(parser->parser);
if (encoder) {
input->buf->encoder = encoder;
}
/* TODO: at one point this should return long probably to make sure that files greater than 2 GiB are handled correctly. */
return (int) result;
return parser->parser->input->consumed +
(parser->parser->input->cur - parser->parser->input->base);
}

PHP_XML_API int
Expand Down
Loading