File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 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)
705705PHP_XML_API int
706706XML_GetCurrentByteIndex (XML_Parser parser )
707707{
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 ;
710723}
711724
712725PHP_XML_API int
You can’t perform that action at this time.
0 commit comments