15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
-
+
|
*/
#include "config.h"
#include <string.h>
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidEncodingException.h"
#import "autorelease.h"
#import "macros.h"
int _OFString_XMLUnescaping_reference;
static OF_INLINE OFString*
parse_numeric_entity(const char *entity, size_t length)
{
|
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
withEncoding: OF_STRING_ENCODING_ASCII
length: 1];
else if (entityLength == 3 && !memcmp(entity, "amp", 3))
[ret appendCString: "&"
withEncoding: OF_STRING_ENCODING_ASCII
length: 1];
else if (entity[0] == '#') {
OFAutoreleasePool *pool;
void *pool;
OFString *tmp;
pool = [[OFAutoreleasePool alloc] init];
pool = objc_autoreleasePoolPush();
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
objc_autoreleasePoolPop(pool);
} else if (delegate != nil) {
OFAutoreleasePool *pool;
void *pool;
OFString *n, *tmp;
pool = [[OFAutoreleasePool alloc] init];
pool = objc_autoreleasePoolPush();
n = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = [delegate string: self
containsUnknownEntityNamed: n];
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
objc_autoreleasePoolPop(pool);
} else
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
last = i + 1;
inEntity = NO;
}
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
-
+
-
+
-
+
-
+
-
+
-
+
|
withEncoding: OF_STRING_ENCODING_ASCII
length: 1];
else if (entityLength == 3 && !memcmp(entity, "amp", 3))
[ret appendCString: "&"
withEncoding: OF_STRING_ENCODING_ASCII
length: 1];
else if (entity[0] == '#') {
OFAutoreleasePool *pool;
void *pool;
OFString *tmp;
pool = [[OFAutoreleasePool alloc] init];
pool = objc_autoreleasePoolPush();
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
objc_autoreleasePoolPop(pool);
} else {
OFAutoreleasePool *pool;
void *pool;
OFString *entityString, *tmp;
pool = [[OFAutoreleasePool alloc] init];
pool = objc_autoreleasePoolPush();
entityString = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = block(self, entityString);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
objc_autoreleasePoolPop(pool);
}
last = i + 1;
inEntity = NO;
}
}
|