Skip to content

Commit 54e662c

Browse files
committed
Revert "Port XML_GetCurrentByteIndex to public APIs"
This reverts commit 8dc799a. Originally, this was going to be deprecated in libxml2 2.14, but this didn't end up happening in the end, and the replacement function that we used got deprecated instead. So fix the deprecation warning by reverting to the original code. Closes GH-18407.
1 parent d6e70e7 commit 54e662c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

ext/xml/compat.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -709,21 +709,8 @@ XML_GetCurrentColumnNumber(XML_Parser parser)
709709
PHP_XML_API int
710710
XML_GetCurrentByteIndex(XML_Parser parser)
711711
{
712-
/* We have to temporarily disable the encoder to satisfy the note from the manual:
713-
* "This function returns byte index according to UTF-8 encoded text disregarding if input is in another encoding."
714-
* Although that should probably be corrected at one point? (TODO) */
715-
xmlCharEncodingHandlerPtr encoder = NULL;
716-
xmlParserInputPtr input = parser->parser->input;
717-
if (input->buf) {
718-
encoder = input->buf->encoder;
719-
input->buf->encoder = NULL;
720-
}
721-
long result = xmlByteConsumed(parser->parser);
722-
if (encoder) {
723-
input->buf->encoder = encoder;
724-
}
725-
/* TODO: at one point this should return long probably to make sure that files greater than 2 GiB are handled correctly. */
726-
return (int) result;
712+
return parser->parser->input->consumed +
713+
(parser->parser->input->cur - parser->parser->input->base);
727714
}
728715

729716
PHP_XML_API int

0 commit comments

Comments
 (0)