summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@webkeks.org>2011-04-09 22:29:53 +0200
committerJonathan Schleifer <js@webkeks.org>2011-04-09 22:29:53 +0200
commit0cd9b3594b1ba5db4579875e52772e94fec41f06 (patch)
tree6570282b5586dcddb7c78838fd0d71f91afb6596
parentd685bd23ba5152a2427807d5b3ce88e8561759c7 (diff)
Merge changes from tip into 0.5 branch.
-rw-r--r--ChangeLog20
-rw-r--r--Info.plist4
-rw-r--r--configure.ac2
-rw-r--r--extra.mk.in2
-rw-r--r--src/OFXMLParser.h1
-rw-r--r--src/OFXMLParser.m107
-rw-r--r--tests/OFXMLParserTests.m15
-rw-r--r--utils/objfw-config.in2
8 files changed, 142 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 142e7eb3..9eccf726 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,26 @@ Legend:
* Changes of existing features or bugfixes.
+ New features.
+ObjFW 0.4-alpha1 -> ObjFW 0.5, 09.04.2011
+ + %@ is now allowed in format strings.
+ + Added of_log for easy logging.
+ * Exceptions have one header per exception now.
+ * Lots of exception improvements.
+ * Huge improvements in XML handling.
+ * Improvements in socket handling, including improved API.
+ * OFStreamObserver is now thread-safe and stops the current observe call when
+ the set of streams to observe is modified.
+ + New class OFURL.
+ + New class OFHTTPRequest.
+ + New class OFCondition.
+ * Improvements in objfw-compile.
+ + Blocks can be used together with Cocoa now.
+ + When linking ObjFW and Cocoa, OFAutoreleasePools are used by both now.
+ + Support for Base64.
+ + Use a real Xcode project instead of just calling make.
+ + Add Haiku to the list of supported platforms.
+ * Lots of small bugfixes and countless small changes. Read the commits!
+
ObjFW 0.3.1 -> 0.4-alpha1, 03.01.2011
* ObjFW is now available under the terms of the QPL, GPLv2 and GPLv3.
+ Support for blocks was added, including a blocks runtime.
diff --git a/Info.plist b/Info.plist
index 5d383126..e43619c3 100644
--- a/Info.plist
+++ b/Info.plist
@@ -17,8 +17,8 @@
<key>CFBundleSignature</key>
<string>OBJFW</string>
<key>CFBundleVersion</key>
- <string>0.4-dev</string>
+ <string>0.6-dev</string>
<key>CFBundleShortVersionString</key>
- <string>0.4-dev</string>
+ <string>0.6-dev</string>
</dict>
</plist>
diff --git a/configure.ac b/configure.ac
index 2243a272..9db251de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(ObjFW, 0.4-dev, js@webkeks.org)
+AC_INIT(ObjFW, 0.6-dev, js@webkeks.org)
AC_CONFIG_SRCDIR(src)
AS_IF([test x"$host" = x"psp"], [
diff --git a/extra.mk.in b/extra.mk.in
index fddfe4a1..278c89af 100644
--- a/extra.mk.in
+++ b/extra.mk.in
@@ -1,6 +1,6 @@
OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@
OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@
-OBJFW_LIB_MAJOR = 3
+OBJFW_LIB_MAJOR = 4
OBJFW_LIB_MINOR = 0
OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}
diff --git a/src/OFXMLParser.h b/src/OFXMLParser.h
index e3f28d0e..1a7794a8 100644
--- a/src/OFXMLParser.h
+++ b/src/OFXMLParser.h
@@ -179,6 +179,7 @@ typedef OFString* (^of_xml_parser_unknown_entity_block_t)(OFXMLParser *parser,
of_xml_parser_unknown_entity_block_t unknownEntityHandler;
#endif
size_t level;
+ BOOL acceptProlog;
size_t lineNumber;
BOOL lastCarriageReturn;
BOOL finishedParsing;
diff --git a/src/OFXMLParser.m b/src/OFXMLParser.m
index fcc9b80b..d202fb39 100644
--- a/src/OFXMLParser.m
+++ b/src/OFXMLParser.m
@@ -51,7 +51,7 @@ transform_string(OFMutableString *cache,
return [cache stringByXMLUnescapingWithDelegate: delegate];
}
-static OF_INLINE OFString*
+static OFString*
namespace_for_prefix(OFString *prefix, OFArray *namespaces)
{
OFDictionary **carray = [namespaces cArray];
@@ -157,6 +157,7 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
@"xmlns", @"http://www.w3.org/2000/xmlns/", nil];
[namespaces addObject: dict];
+ acceptProlog = YES;
lineNumber = 1;
[pool release];
@@ -267,7 +268,7 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
/*
* The following methods handle the different states of the parser. They are
- * lookup up in +[initialize] and put in a lookup table to speed things up.
+ * looked up in +[initialize] and put in a lookup table to speed things up.
* One dispatch for every character would be way too slow!
*/
@@ -278,8 +279,9 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
{
size_t len;
- if (finishedParsing && buf[*i] != ' ' && buf[*i] != '\t' &&
- buf[*i] != '\n' && buf[*i] != '\r' && buf[*i] != '<')
+ if ((finishedParsing || [previous count] < 1) && buf[*i] != ' ' &&
+ buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r' &&
+ buf[*i] != '<')
@throw [OFMalformedXMLException newWithClass: isa
parser: self];
@@ -319,7 +321,7 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
i: (size_t*)i
last: (size_t*)last
{
- if (finishedParsing && buf[*i] != '!')
+ if (finishedParsing && buf[*i] != '!' && buf[*i] != '?')
@throw [OFMalformedXMLException newWithClass: isa
parser: self];
@@ -332,19 +334,104 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
case '/':
*last = *i + 1;
state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
+ acceptProlog = NO;
break;
case '!':
*last = *i + 1;
state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
+ acceptProlog = NO;
break;
default:
state = OF_XMLPARSER_IN_TAG_NAME;
+ acceptProlog = NO;
(*i)--;
break;
}
}
-/* Inside prolog */
+/* <?xml […]?> */
+- (BOOL)_parseXMLProcessingInstructions: (OFString*)pi
+{
+ const char *pi_c;
+ size_t i, last, pi_len;
+ int xstate = 0;
+ OFString *attr = nil;
+ OFString *val = nil;
+ char xdelim = 0;
+
+ if (!acceptProlog)
+ return NO;
+
+ acceptProlog = NO;
+
+ pi = [pi substringFromIndex: 3
+ toIndex: [pi length]];
+ pi = [pi stringByDeletingLeadingAndTrailingWhitespaces];
+
+ pi_c = [pi cString];
+ pi_len = [pi cStringLength];
+
+ for (i = last = 0; i < pi_len; i++) {
+ switch (xstate) {
+ case 0:
+ if (pi_c[i] == ' ' || pi_c[i] == '\t' ||
+ pi_c[i] == '\r' || pi_c[i] == '\n')
+ continue;
+
+ last = i;
+ xstate = 1;
+ i--;
+
+ break;
+ case 1:
+ if (pi_c[i] != '=')
+ continue;
+
+ attr = [OFString stringWithCString: pi_c + last
+ length: i - last];
+ last = i + 1;
+ xstate = 2;
+
+ break;
+ case 2:
+ if (pi_c[i] != '\'' && pi_c[i] != '"')
+ return NO;
+
+ xdelim = pi_c[i];
+ last = i + 1;
+ xstate = 3;
+
+ break;
+ case 3:
+ if (pi_c[i] != xdelim)
+ continue;
+
+ val = [OFString stringWithCString: pi_c + last
+ length: i - last];
+
+ if ([attr isEqual: @"version"])
+ if (![val hasPrefix: @"1."])
+ return NO;
+
+ if ([attr isEqual: @"encoding"])
+ if ([val caseInsensitiveCompare: @"utf-8"] !=
+ OF_ORDERED_SAME)
+ return NO;
+
+ last = i + 1;
+ xstate = 0;
+
+ break;
+ }
+ }
+
+ if (xstate != 0)
+ return NO;
+
+ return YES;
+}
+
+/* Inside processing instructions */
- (void)_parseInProcessingInstructionsWithBuffer: (const char*)buf
i: (size_t*)i
last: (size_t*)last
@@ -371,6 +458,14 @@ resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
*/
pi->isa = [OFString class];
+ if ([pi isEqual: @"xml"] || [pi hasPrefix: @"xml "] ||
+ [pi hasPrefix: @"xml\t"] || [pi hasPrefix: @"xml\r"] ||
+ [pi hasPrefix: @"xml\n"])
+ if (![self _parseXMLProcessingInstructions: pi])
+ @throw [OFMalformedXMLException
+ newWithClass: isa
+ parser: self];
+
[delegate parser: self
foundProcessingInstructions: pi];
diff --git a/tests/OFXMLParserTests.m b/tests/OFXMLParserTests.m
index d1ce7246..1ea79b75 100644
--- a/tests/OFXMLParserTests.m
+++ b/tests/OFXMLParserTests.m
@@ -376,6 +376,21 @@ enum event_type {
EXPECT_EXCEPTION(@"Detection of junk after the document #2",
OFMalformedXMLException, [parser parseString: @"<!["])
+ parser = [OFXMLParser parser];
+ EXPECT_EXCEPTION(@"Detection of invalid XML processing instructions #1",
+ OFMalformedXMLException,
+ [parser parseString: @"<?xml version='2.0'?>"])
+
+ parser = [OFXMLParser parser];
+ EXPECT_EXCEPTION(@"Detection of invalid XML processing instructions #2",
+ OFMalformedXMLException,
+ [parser parseString: @"<?xml encoding='UTF-7'?>"])
+
+ parser = [OFXMLParser parser];
+ EXPECT_EXCEPTION(@"Detection of invalid XML processing instructions #3",
+ OFMalformedXMLException,
+ [parser parseString: @"<x><?xml?></x>"])
+
[pool drain];
}
@end
diff --git a/utils/objfw-config.in b/utils/objfw-config.in
index 84e01bf6..77cc4db5 100644
--- a/utils/objfw-config.in
+++ b/utils/objfw-config.in
@@ -37,7 +37,7 @@ PLUGIN_CFLAGS="@PLUGIN_CFLAGS@"
PLUGIN_LDFLAGS="@PLUGIN_LDFLAGS@"
PLUGIN_SUFFIX="@PLUGIN_SUFFIX@"
PROG_SUFFIX="@EXEEXT@"
-VERSION="0.4-dev"
+VERSION="0.6-dev"
show_help() {
cat <<__EOF__