Skip to content

Commit f203d83

Browse files
committed
Merge commit 'f8a8c1f59db355b46962577e7b74f1a1e8149dc6'
2 parents cb2bf9f + f8a8c1f commit f203d83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+578
-504
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Makefile.in
1515
aclocal.m4
1616
autom4te.cache
1717
bissect*
18+
compile
1819
config.guess
1920
config.h
2021
config.h.in
@@ -59,6 +60,7 @@ install-sh
5960
libtool
6061
libxml-2.0-uninstalled.pc
6162
libxml-2.0.pc
63+
libxml2-config.cmake
6264
libxml2.la
6365
libxml2.spec
6466
list

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ matrix:
1313
env: CFLAGS="-O2 -std=c89 -D_XOPEN_SOURCE=700 -Werror -Wno-error=unused-function"
1414
# clang with AddressSanitizer and UndefinedBehaviorSanitizer.
1515
- compiler: clang
16+
sudo: required
1617
dist: trusty
1718
env: CONFIG="--without-python"
1819
CFLAGS="-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize=float-divide-by-zero,pointer-overflow -fno-sanitize-recover=all -Werror -Wno-error=unused-function -Wno-error=cast-align"

HTMLparser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ static const char * const htmlStartClose[] = {
10841084
"menu", "p", "head", "ul", NULL,
10851085
"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", FONTSTYLE, NULL,
10861086
"div", "p", "head", NULL,
1087-
"noscript", "p", NULL,
1087+
"noscript", "script", NULL,
10881088
"center", "font", "b", "i", "p", "head", NULL,
10891089
"a", "a", "head", NULL,
10901090
"caption", "p", NULL,
@@ -3635,13 +3635,13 @@ htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
36353635
*/
36363636
processed = ctxt->input->cur - ctxt->input->base;
36373637
xmlBufShrink(ctxt->input->buf->buffer, processed);
3638-
nbchars = xmlCharEncInput(ctxt->input->buf, 0);
3638+
nbchars = xmlCharEncInput(ctxt->input->buf, 1);
3639+
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
36393640
if (nbchars < 0) {
36403641
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
36413642
"htmlCheckEncoding: encoder error\n",
36423643
NULL, NULL);
36433644
}
3644-
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
36453645
}
36463646
}
36473647
}

HTMLtree.c

Lines changed: 44 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -502,16 +502,16 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
502502
if (handler == NULL)
503503
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
504504
}
505+
} else {
506+
/*
507+
* Fallback to HTML or ASCII when the encoding is unspecified
508+
*/
509+
if (handler == NULL)
510+
handler = xmlFindCharEncodingHandler("HTML");
511+
if (handler == NULL)
512+
handler = xmlFindCharEncodingHandler("ascii");
505513
}
506514

507-
/*
508-
* Fallback to HTML or ASCII when the encoding is unspecified
509-
*/
510-
if (handler == NULL)
511-
handler = xmlFindCharEncodingHandler("HTML");
512-
if (handler == NULL)
513-
handler = xmlFindCharEncodingHandler("ascii");
514-
515515
/*
516516
* save the content to a temp buffer.
517517
*/
@@ -570,33 +570,22 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
570570
xmlCharEncoding enc;
571571

572572
enc = xmlParseCharEncoding(encoding);
573-
if (enc != cur->charset) {
574-
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
575-
/*
576-
* Not supported yet
577-
*/
578-
*mem = NULL;
579-
*size = 0;
580-
return;
581-
}
582-
573+
if (enc != XML_CHAR_ENCODING_UTF8) {
583574
handler = xmlFindCharEncodingHandler(encoding);
584575
if (handler == NULL)
585576
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
586577

587-
} else {
588-
handler = xmlFindCharEncodingHandler(encoding);
589578
}
579+
} else {
580+
/*
581+
* Fallback to HTML or ASCII when the encoding is unspecified
582+
*/
583+
if (handler == NULL)
584+
handler = xmlFindCharEncodingHandler("HTML");
585+
if (handler == NULL)
586+
handler = xmlFindCharEncodingHandler("ascii");
590587
}
591588

592-
/*
593-
* Fallback to HTML or ASCII when the encoding is unspecified
594-
*/
595-
if (handler == NULL)
596-
handler = xmlFindCharEncodingHandler("HTML");
597-
if (handler == NULL)
598-
handler = xmlFindCharEncodingHandler("ascii");
599-
600589
buf = xmlAllocOutputBufferInternal(handler);
601590
if (buf == NULL) {
602591
*mem = NULL;
@@ -1101,30 +1090,21 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
11011090
xmlCharEncoding enc;
11021091

11031092
enc = xmlParseCharEncoding(encoding);
1104-
if (enc != cur->charset) {
1105-
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
1106-
/*
1107-
* Not supported yet
1108-
*/
1109-
return(-1);
1110-
}
1111-
1093+
if (enc != XML_CHAR_ENCODING_UTF8) {
11121094
handler = xmlFindCharEncodingHandler(encoding);
11131095
if (handler == NULL)
11141096
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
1115-
} else {
1116-
handler = xmlFindCharEncodingHandler(encoding);
11171097
}
1098+
} else {
1099+
/*
1100+
* Fallback to HTML or ASCII when the encoding is unspecified
1101+
*/
1102+
if (handler == NULL)
1103+
handler = xmlFindCharEncodingHandler("HTML");
1104+
if (handler == NULL)
1105+
handler = xmlFindCharEncodingHandler("ascii");
11181106
}
11191107

1120-
/*
1121-
* Fallback to HTML or ASCII when the encoding is unspecified
1122-
*/
1123-
if (handler == NULL)
1124-
handler = xmlFindCharEncodingHandler("HTML");
1125-
if (handler == NULL)
1126-
handler = xmlFindCharEncodingHandler("ascii");
1127-
11281108
buf = xmlOutputBufferCreateFile(f, handler);
11291109
if (buf == NULL) return(-1);
11301110
htmlDocContentDumpOutput(buf, cur, NULL);
@@ -1160,28 +1140,21 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
11601140
xmlCharEncoding enc;
11611141

11621142
enc = xmlParseCharEncoding(encoding);
1163-
if (enc != cur->charset) {
1164-
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
1165-
/*
1166-
* Not supported yet
1167-
*/
1168-
return(-1);
1169-
}
1170-
1143+
if (enc != XML_CHAR_ENCODING_UTF8) {
11711144
handler = xmlFindCharEncodingHandler(encoding);
11721145
if (handler == NULL)
11731146
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
11741147
}
1148+
} else {
1149+
/*
1150+
* Fallback to HTML or ASCII when the encoding is unspecified
1151+
*/
1152+
if (handler == NULL)
1153+
handler = xmlFindCharEncodingHandler("HTML");
1154+
if (handler == NULL)
1155+
handler = xmlFindCharEncodingHandler("ascii");
11751156
}
11761157

1177-
/*
1178-
* Fallback to HTML or ASCII when the encoding is unspecified
1179-
*/
1180-
if (handler == NULL)
1181-
handler = xmlFindCharEncodingHandler("HTML");
1182-
if (handler == NULL)
1183-
handler = xmlFindCharEncodingHandler("ascii");
1184-
11851158
/*
11861159
* save the content to a temp buffer.
11871160
*/
@@ -1221,30 +1194,23 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
12211194
xmlCharEncoding enc;
12221195

12231196
enc = xmlParseCharEncoding(encoding);
1224-
if (enc != cur->charset) {
1225-
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
1226-
/*
1227-
* Not supported yet
1228-
*/
1229-
return(-1);
1230-
}
1231-
1197+
if (enc != XML_CHAR_ENCODING_UTF8) {
12321198
handler = xmlFindCharEncodingHandler(encoding);
12331199
if (handler == NULL)
12341200
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
12351201
}
12361202
htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
12371203
} else {
12381204
htmlSetMetaEncoding(cur, (const xmlChar *) "UTF-8");
1239-
}
12401205

1241-
/*
1242-
* Fallback to HTML or ASCII when the encoding is unspecified
1243-
*/
1244-
if (handler == NULL)
1245-
handler = xmlFindCharEncodingHandler("HTML");
1246-
if (handler == NULL)
1247-
handler = xmlFindCharEncodingHandler("ascii");
1206+
/*
1207+
* Fallback to HTML or ASCII when the encoding is unspecified
1208+
*/
1209+
if (handler == NULL)
1210+
handler = xmlFindCharEncodingHandler("HTML");
1211+
if (handler == NULL)
1212+
handler = xmlFindCharEncodingHandler("ascii");
1213+
}
12481214

12491215
/*
12501216
* save the content to a temp buffer.

SAX2.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,11 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
16651665
#ifdef DEBUG_SAX_TREE
16661666
xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
16671667
#endif
1668-
nodePush(ctxt, ret);
1668+
if (nodePush(ctxt, ret) < 0) {
1669+
xmlUnlinkNode(ret);
1670+
xmlFreeNode(ret);
1671+
return;
1672+
}
16691673

16701674
/*
16711675
* Link the child element
@@ -2257,6 +2261,7 @@ xmlSAX2StartElementNs(void *ctx,
22572261
ctxt->freeElems = ret->next;
22582262
ctxt->freeElemsNr--;
22592263
memset(ret, 0, sizeof(xmlNode));
2264+
ret->doc = ctxt->myDoc;
22602265
ret->type = XML_ELEMENT_NODE;
22612266

22622267
if (ctxt->dictNames)
@@ -2336,7 +2341,11 @@ xmlSAX2StartElementNs(void *ctx,
23362341
/*
23372342
* We are parsing a new node.
23382343
*/
2339-
nodePush(ctxt, ret);
2344+
if (nodePush(ctxt, ret) < 0) {
2345+
xmlUnlinkNode(ret);
2346+
xmlFreeNode(ret);
2347+
return;
2348+
}
23402349

23412350
/*
23422351
* Link the child element

autogen.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ fi
6767
# Replaced by autoreconf below
6868
autoreconf -if -Wall
6969

70+
if ! grep -q pkg.m4 aclocal.m4; then
71+
cat <<EOF
72+
73+
Couldn't find pkg.m4 from pkg-config. Install the appropriate package for
74+
your distribution or set ACLOCAL_PATH to the directory containing pkg.m4.
75+
EOF
76+
exit 1
77+
fi
78+
7079
cd $THEDIR
7180

7281
if test x$OBJ_DIR != x; then
@@ -76,6 +85,11 @@ fi
7685

7786
if test -z "$NOCONFIGURE"; then
7887
$srcdir/configure $EXTRA_ARGS "$@"
79-
echo
80-
echo "Now type 'make' to compile libxml2."
88+
if test "$?" -ne 0; then
89+
echo
90+
echo "Configure script failed, check config.log for more info."
91+
else
92+
echo
93+
echo "Now type 'make' to compile libxml2."
94+
fi
8195
fi

c14n.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,15 +1797,6 @@ xmlC14NNewCtx(xmlDocPtr doc,
17971797
return (NULL);
17981798
}
17991799

1800-
/*
1801-
* Validate the XML document encoding value, if provided.
1802-
*/
1803-
if (doc->charset != XML_CHAR_ENCODING_UTF8) {
1804-
xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8,
1805-
"xmlC14NNewCtx: source document not in UTF8\n");
1806-
return (NULL);
1807-
}
1808-
18091800
/*
18101801
* Allocate a new xmlC14NCtxPtr and fill the fields.
18111802
*/

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ AC_CANONICAL_HOST
99

1010
LIBXML_MAJOR_VERSION=2
1111
LIBXML_MINOR_VERSION=9
12-
LIBXML_MICRO_VERSION=8
12+
LIBXML_MICRO_VERSION=9
1313
LIBXML_MICRO_VERSION_SUFFIX=
1414
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
1515
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION

0 commit comments

Comments
 (0)