File: libxml2-2.14.patch

package info (click to toggle)
parser 3.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,520 kB
  • sloc: cpp: 35,302; sh: 15,643; ansic: 10,375; yacc: 1,378; makefile: 242
file content (192 lines) | stat: -rw-r--r-- 5,430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
Description: Fix FTBFS with libxml2/2.14.x.
Origin: upstream, commit:f21c71f, commit:80daf2b
Bug-Debian: https://bugs.debian.org/1106637
Forwarded: not-needed
Last-Update: 2025-08-10
---

--- parser.orig/src/include/pa_charset.h
+++ parser/src/include/pa_charset.h
@@ -8,7 +8,7 @@
 #ifndef PA_CHARSET_H
 #define PA_CHARSET_H
 
-#define IDENT_PA_CHARSET_H "$Id: pa_charset.h,v 1.60 2024/12/11 21:57:35 moko Exp $"
+#define IDENT_PA_CHARSET_H "$Id: pa_charset.h,v 1.62 2025/06/28 15:38:04 moko Exp $"
 
 
 #include "pa_exception.h"
@@ -75,10 +75,6 @@
 
 	void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found);
 
-#ifdef XML
-	xmlCharEncodingHandler& transcoder(const String::Body NAME);
-#endif
-
 public:
 
 	unsigned char pcre_tables[tables_length];
@@ -139,7 +135,6 @@
 
 private:
 	void addEncoding(char* name_cstr);
-	void initTranscoder(const String::Body name, const char* name_cstr);
 
 public:
 	/// converts xmlChar* null-terminated string to char* 
@@ -158,7 +153,8 @@
 
 private:
 
-	xmlCharEncodingHandler* ftranscoder;
+	xmlCharEncodingInputFunc ftranscoder_input;
+	xmlCharEncodingOutputFunc ftranscoder_output;
 
 #endif
 
--- parser.orig/src/main/pa_charset.C
+++ parser/src/main/pa_charset.C
@@ -11,15 +11,13 @@
 // we are using some pcre_internal.h stuff as well
 #include "../lib/pcre/pa_pcre_internal.h"
 
-volatile const char * IDENT_PA_CHARSET_C="$Id: pa_charset.C,v 1.115 2024/12/11 21:57:35 moko Exp $" IDENT_PA_CHARSET_H;
+volatile const char * IDENT_PA_CHARSET_C="$Id: pa_charset.C,v 1.117 2025/06/28 15:42:00 moko Exp $" IDENT_PA_CHARSET_H;
 
 #ifdef XML
 #include "libxml/xmlmemory.h"
 #include "libxml/encoding.h"
 #endif
 
-//#define PA_PATCHED_LIBXML_BACKWARD
-
 // reduce memory usage by pre-calculation utf-8 string length
 #define PRECALCULATE_DEST_LENGTH
 
@@ -125,10 +123,6 @@
 		// grab default onces [for UTF-8 so to be able to make a-z =>A-Z
 		memcpy(pcre_tables, pa_pcre_default_tables, sizeof(pcre_tables));
 	}
-
-#ifdef XML
-	initTranscoder(FNAME, FNAME_CSTR);
-#endif
 }
 
 void Charset::load_definition(Request_charsets& acharsets, const String& afile_spec) {
@@ -993,29 +987,6 @@
 #ifdef XML
 
 static const Charset::Tables* tables[MAX_CHARSETS];
-static xmlCharEncodingHandler xml_encoding_handlers[MAX_CHARSETS];
-
-#ifdef PA_PATCHED_LIBXML_BACKWARD
-
-#define declareXml256ioFuncs(i) \
-	static int xml256CharEncodingInputFunc##i( \
-		unsigned char *out, int *outlen, \
-		const unsigned char *in, int *inlen, void*) { \
-		return transcodeToUTF8( \
-			in, *inlen, \
-			out, *outlen, \
-			*tables[i]); \
-	} \
-	static int xml256CharEncodingOutputFunc##i( \
-		unsigned char *out, int *outlen, \
-		const unsigned char *in, int *inlen, void*) { \
-		return transcodeFromUTF8( \
-			in, *inlen, \
-			out, *outlen, \
-			*tables[i]); \
-	}
-
-#else
 
 #define declareXml256ioFuncs(i) \
 	static int xml256CharEncodingInputFunc##i( \
@@ -1035,9 +1006,6 @@
 			*tables[i]); \
 	}
 
-#endif
-
-
 declareXml256ioFuncs(0)	declareXml256ioFuncs(1)
 declareXml256ioFuncs(2)	declareXml256ioFuncs(3)
 declareXml256ioFuncs(4)	declareXml256ioFuncs(5)
@@ -1064,28 +1032,14 @@
 	if(handlers_count==MAX_CHARSETS)
 		throw Exception(0, 0, "already allocated %d handlers, no space for new encoding '%s'", MAX_CHARSETS, name_cstr);
 
-	xmlCharEncodingHandler* handler=&xml_encoding_handlers[handlers_count];
-	{
-		handler->name=name_cstr;
-		handler->input=inputFuncs[handlers_count]; 
-		handler->output=outputFuncs[handlers_count]; 
-		::tables[handlers_count]=&tables;
-		handlers_count++;
-	}
-	
+	ftranscoder_input=inputFuncs[handlers_count];
+	ftranscoder_output=outputFuncs[handlers_count];
+	::tables[handlers_count++]=&tables;
+
+	xmlCharEncodingHandler* handler=xmlNewCharEncodingHandler(name_cstr, ftranscoder_input, ftranscoder_output);
+	if(!handler)
+		throw Exception(0, new String(name_cstr, String::L_TAINTED), "unable to register XML encoding handler");
 	xmlRegisterCharEncodingHandler(handler);
-
-}
-
-void Charset::initTranscoder(const String::Body NAME, const char* name_cstr) {
-	ftranscoder=xmlFindCharEncodingHandler(name_cstr);
-	transcoder(NAME); // check right way
-}
-
-xmlCharEncodingHandler& Charset::transcoder(const String::Body NAME) {
-	if(!ftranscoder)
-		throw Exception(PARSER_RUNTIME, new String(NAME, String::L_TAINTED), "unsupported encoding");
-	return *ftranscoder;
 }
 
 String::C Charset::transcode_cstr(const xmlChar* s) {
@@ -1100,14 +1054,8 @@
 	char *out=new(PointerFreeGC) char[outlen+1];
 	
 	int error;
-	if(xmlCharEncodingOutputFunc output=transcoder(FNAME).output) {
-		error=output(
-			(unsigned char*)out, &outlen,
-			(const unsigned char*)s, &inlen
-#ifdef PA_PATCHED_LIBXML_BACKWARD
-			,0
-#endif
-			);
+	if(!fisUTF8) {
+		error=ftranscoder_output((unsigned char*)out, &outlen, (const unsigned char*)s, &inlen);
 	} else {
 		memcpy(out, s, outlen=inlen);
 		error=0;
@@ -1131,19 +1079,13 @@
 #ifndef NDEBUG
 	int saved_outlen;
 #endif
-	if(xmlCharEncodingInputFunc input=transcoder(FNAME).input) {
+	if(!fisUTF8) {
 		outlen=buf_size*6/*max UTF8 bytes per char*/;
 #ifndef NDEBUG
 		saved_outlen=outlen;
 #endif
 		out=(xmlChar*)xmlMalloc(outlen+1);
-		error=input(
-			out, &outlen,
-			(const unsigned char*)buf, (int*)&buf_size
-#ifdef PA_PATCHED_LIBXML_BACKWARD
-			,0
-#endif
-			);
+		error=ftranscoder_input(out, &outlen, (const unsigned char*)buf, (int*)&buf_size);
 	} else {
 		outlen=buf_size;
 #ifndef NDEBUG