mirror of
				https://gitlab.gnome.org/GNOME/libxml2.git
				synced 2025-10-26 00:37:43 +03:00 
			
		
		
		
	parser: Don't modify SAX2 handler if XML_PARSE_SAX1 is set
It's a bad idea to modify members of the SAX handler struct for option state management. Ideally, ctxt->options should be the preferred source of truth.
This commit is contained in:
		
							
								
								
									
										7
									
								
								parser.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								parser.c
									
									
									
									
									
								
							| @@ -950,7 +950,9 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) { | |||||||
|      * Only enable SAX2 if there SAX2 element handlers, except when there |      * Only enable SAX2 if there SAX2 element handlers, except when there | ||||||
|      * are no element handlers at all. |      * are no element handlers at all. | ||||||
|      */ |      */ | ||||||
|     if ((sax) && (sax->initialized == XML_SAX2_MAGIC) && |     if (((ctxt->options & XML_PARSE_SAX1) == 0) && | ||||||
|  |         (sax) && | ||||||
|  |         (sax->initialized == XML_SAX2_MAGIC) && | ||||||
|         ((sax->startElementNs != NULL) || |         ((sax->startElementNs != NULL) || | ||||||
|          (sax->endElementNs != NULL) || |          (sax->endElementNs != NULL) || | ||||||
|          ((sax->startElement == NULL) && (sax->endElement == NULL)))) |          ((sax->startElement == NULL) && (sax->endElement == NULL)))) | ||||||
| @@ -13412,9 +13414,6 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options) | |||||||
|     } |     } | ||||||
| #ifdef LIBXML_SAX1_ENABLED | #ifdef LIBXML_SAX1_ENABLED | ||||||
|     if (options & XML_PARSE_SAX1) { |     if (options & XML_PARSE_SAX1) { | ||||||
|         ctxt->sax->startElementNs = NULL; |  | ||||||
|         ctxt->sax->endElementNs = NULL; |  | ||||||
|         ctxt->sax->initialized = 1; |  | ||||||
|         options -= XML_PARSE_SAX1; |         options -= XML_PARSE_SAX1; | ||||||
| 	ctxt->options |= XML_PARSE_SAX1; | 	ctxt->options |= XML_PARSE_SAX1; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user