File tree 1 file changed +15
-2
lines changed 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -705,8 +705,21 @@ XML_GetCurrentColumnNumber(XML_Parser parser)
705
705
PHP_XML_API int
706
706
XML_GetCurrentByteIndex (XML_Parser parser )
707
707
{
708
- return parser -> parser -> input -> consumed +
709
- (parser -> parser -> input -> cur - parser -> parser -> input -> base );
708
+ /* We have to temporarily disable the encoder to satisfy the note from the manual:
709
+ * "This function returns byte index according to UTF-8 encoded text disregarding if input is in another encoding."
710
+ * Although that should probably be corrected at one point? (TODO) */
711
+ xmlCharEncodingHandlerPtr encoder = NULL ;
712
+ xmlParserInputPtr input = parser -> parser -> input ;
713
+ if (input -> buf ) {
714
+ encoder = input -> buf -> encoder ;
715
+ input -> buf -> encoder = NULL ;
716
+ }
717
+ long result = xmlByteConsumed (parser -> parser );
718
+ if (encoder ) {
719
+ input -> buf -> encoder = encoder ;
720
+ }
721
+ /* TODO: at one point this should return long probably to make sure that files greater than 2 GiB are handled correctly. */
722
+ return (int ) result ;
710
723
}
711
724
712
725
PHP_XML_API int
You can’t perform that action at this time.
0 commit comments