Skip to content

Commit d635c87

Browse files
committed
xml: Fix deprecation properly by backporting the modern-but-actually-old implementation
1 parent fe070fc commit d635c87

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

ext/xml/compat.c

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

733718
PHP_XML_API int

0 commit comments

Comments
 (0)