File tree Expand file tree Collapse file tree 5 files changed +49
-6
lines changed Expand file tree Collapse file tree 5 files changed +49
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ PHP                                                                        NEWS
66  . Fixed bug GH-14792 (Compilation failure on pdo_* extensions).
77    (Peter Kokot)
88
9+ - XML:
10+   . Fixed bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on
11+     64-bit builds). (nielsdos)
12+ 
91304 Jul 2024, PHP 8.4.0alpha1
1014
1115- BCMath:
Original file line number Diff line number Diff line change @@ -292,6 +292,11 @@ PHP 8.4 INTERNALS UPGRADE NOTES
292292   - The ext/session/php_session.h doesn't transitively include the
293293     ext/hash/php_hash.h header anymore.
294294
295+  i. ext/xml
296+    - Made the expat compatibility wrapper XML_GetCurrentByteIndex return a long
297+      instead of an int. This corresponds to the XML_Index type when
298+      XML_LARGE_SIZE is not used in expat.
299+ 
295300========================
2963014. OpCode changes
297302========================
Original file line number Diff line number Diff line change @@ -686,7 +686,7 @@ XML_GetCurrentColumnNumber(XML_Parser parser)
686686	return  parser -> parser -> input -> col ;
687687}
688688
689- PHP_XML_API  int 
689+ PHP_XML_API  long 
690690XML_GetCurrentByteIndex (XML_Parser  parser )
691691{
692692	/* We have to temporarily disable the encoder to satisfy the note from the manual: 
@@ -702,16 +702,15 @@ XML_GetCurrentByteIndex(XML_Parser parser)
702702	if  (encoder ) {
703703		input -> buf -> encoder  =  encoder ;
704704	}
705- 	/* TODO: at one point this should return long probably to make sure that files greater than 2 GiB are handled correctly. */ 
706- 	return  (int ) result ;
705+ 	return  result ;
707706}
708707
709708PHP_XML_API  int 
710709XML_GetCurrentByteCount (XML_Parser  parser )
711710{
712- 	/* WARNING : this is identical to ByteIndex; it should probably 
711+ 	/* TODO : this is identical to ByteIndex; it should probably 
713712	 * be different */ 
714- 	return  XML_GetCurrentByteIndex (parser );
713+ 	return  ( int )  XML_GetCurrentByteIndex (parser );
715714}
716715
717716PHP_XML_API  const  XML_Char  * XML_ExpatVersion (void )
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ PHP_XML_API int  XML_GetErrorCode(XML_Parser);
144144PHP_XML_API  const  XML_Char  * XML_ErrorString (int );
145145PHP_XML_API  int   XML_GetCurrentLineNumber (XML_Parser );
146146PHP_XML_API  int   XML_GetCurrentColumnNumber (XML_Parser );
147- PHP_XML_API  int    XML_GetCurrentByteIndex (XML_Parser );
147+ PHP_XML_API  long XML_GetCurrentByteIndex (XML_Parser );
148148PHP_XML_API  int   XML_GetCurrentByteCount (XML_Parser );
149149PHP_XML_API  const  XML_Char  * XML_ExpatVersion (void );
150150PHP_XML_API  void  XML_ParserFree (XML_Parser );
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds)
3+ --CREDITS--
4+ dev at b65sol dot com
5+ --EXTENSIONS--
6+ xml
7+ --INI--
8+ memory_limit=-1
9+ --SKIPIF--
10+ <?php 
11+ require  __DIR__  . '/libxml_expat_skipif.inc ' ;
12+ skipif (want_expat: false );
13+ if  (getenv ("SKIP_SLOW_TESTS " )) die ("skip slow test " );
14+ if  (PHP_INT_SIZE  != 8 ) die ("skip 64-bit only " );
15+ ?> 
16+ --FILE--
17+ <?php 
18+ $ parserxml_parser_create ('UTF-8 ' );
19+ xml_set_element_handler ( $ parser'startelement ' , null  );
20+ 
21+ $ emptylongstr_repeat ('  ' , 1024 *1024 );
22+ xml_parse ($ parser'<root><i></i><b/><ext>Hello</ext> ' , false );
23+ for ($ i0 ; $ i2200 ; $ i
24+     xml_parse ($ parser$ emptylongfalse );
25+ }
26+ xml_parse ($ parser'<ext></ext><ext></ext></root> ' , false );
27+ 
28+ function  startelement ($ parser$ name$ attribute
29+     if  ( $ name'EXT '  ) { echo  "Byte Index: " , xml_get_current_byte_index ($ parser"\n" ; }
30+ }
31+ ?> 
32+ --EXPECT--
33+ Byte Index:21
34+ Byte Index:2306867237
35+ Byte Index:2306867248
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments