Browse Source

Update to latest version on github.

mingodad 11 years ago
parent
commit
f2345e84ff
8 changed files with 59 additions and 43 deletions
  1. 24 14
      gumbo/README.md
  2. 3 1
      gumbo/error.h
  3. 0 3
      gumbo/gumbo.cbp
  4. 1 1
      gumbo/gumbo.depend
  5. 5 0
      gumbo/gumbo.h
  6. 15 23
      gumbo/parser.c
  7. 6 0
      gumbo/utf8.c
  8. 5 1
      gumbo/util.h

+ 24 - 14
gumbo/README.md

@@ -46,21 +46,27 @@ Installation
 To build and install the library, issue the standard UNIX incantation from
 To build and install the library, issue the standard UNIX incantation from
 the root of the distribution:
 the root of the distribution:
 
 
-    $ ./autogen.sh
-    $ ./configure
-    $ make
-    $ sudo make install
+```bash
+$ ./autogen.sh
+$ ./configure
+$ make
+$ sudo make install
+```
 
 
 Gumbo comes with full pkg-config support, so you can use the pkg-config to
 Gumbo comes with full pkg-config support, so you can use the pkg-config to
 print the flags needed to link your program against it:
 print the flags needed to link your program against it:
 
 
-    $ pkg-config --cflags gumbo         # print compiler flags
-    $ pkg-config --libs gumbo           # print linker flags
-    $ pkg-config --cflags --libs gumbo  # print both
+```bash
+$ pkg-config --cflags gumbo         # print compiler flags
+$ pkg-config --libs gumbo           # print linker flags
+$ pkg-config --cflags --libs gumbo  # print both
+```
 
 
 For example:
 For example:
 
 
-    $ gcc my_program.c `pkg-config --cflags --libs gumbo`
+```bash
+$ gcc my_program.c `pkg-config --cflags --libs gumbo`
+```
 
 
 See the pkg-config man page for more info.
 See the pkg-config man page for more info.
 
 
@@ -73,18 +79,22 @@ unzipped.  The googletest maintainers recommend against using
 `make install`; instead, symlink the root googletest directory to 'gtest'
 `make install`; instead, symlink the root googletest directory to 'gtest'
 inside gumbo's root directory, and then `make check`:
 inside gumbo's root directory, and then `make check`:
 
 
-    $ unzip gtest-1.6.0.zip
-    $ cd gumbo-*
-    $ ln -s ../gtest-1.6.0 gtest
-    $ make check
+```bash
+$ unzip gtest-1.6.0.zip
+$ cd gumbo-*
+$ ln -s ../gtest-1.6.0 gtest
+$ make check
+```
 
 
 Gumbo's `make check` has code to automatically configure & build gtest and
 Gumbo's `make check` has code to automatically configure & build gtest and
 then link in the library.
 then link in the library.
 
 
 Debian and Fedora users can install libgtest with:
 Debian and Fedora users can install libgtest with:
 
 
-    $ apt-get install libgtest-dev  # Debian/Ubuntu
-    $ yum install gtest-devel       # CentOS/Fedora
+```bash
+$ apt-get install libgtest-dev  # Debian/Ubuntu
+$ yum install gtest-devel       # CentOS/Fedora
+```
 
 
 Note for Ubuntu users: libgtest-dev package only install source files.
 Note for Ubuntu users: libgtest-dev package only install source files.
 You have to make libraries yourself using cmake:
 You have to make libraries yourself using cmake:

+ 3 - 1
gumbo/error.h

@@ -18,7 +18,9 @@
 
 
 #ifndef GUMBO_ERROR_H_
 #ifndef GUMBO_ERROR_H_
 #define GUMBO_ERROR_H_
 #define GUMBO_ERROR_H_
-
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS
+#endif
 #include <stdint.h>
 #include <stdint.h>
 
 
 #include "gumbo.h"
 #include "gumbo.h"

+ 0 - 3
gumbo/gumbo.cbp

@@ -51,9 +51,6 @@
 		<Unit filename="error.h" />
 		<Unit filename="error.h" />
 		<Unit filename="gumbo.h" />
 		<Unit filename="gumbo.h" />
 		<Unit filename="insertion_mode.h" />
 		<Unit filename="insertion_mode.h" />
-		<Unit filename="main.c">
-			<Option compilerVar="CC" />
-		</Unit>
 		<Unit filename="parser.c">
 		<Unit filename="parser.c">
 			<Option compilerVar="CC" />
 			<Option compilerVar="CC" />
 		</Unit>
 		</Unit>

+ 1 - 1
gumbo/gumbo.depend

@@ -10,7 +10,7 @@
 1380152090 /home/mingo/dev/SquiLu/gumbo/attribute.h
 1380152090 /home/mingo/dev/SquiLu/gumbo/attribute.h
 	"gumbo.h"
 	"gumbo.h"
 
 
-1380152090 /home/mingo/dev/SquiLu/gumbo/gumbo.h
+1386356289 /home/mingo/dev/SquiLu/gumbo/gumbo.h
 	<stdbool.h>
 	<stdbool.h>
 	<stddef.h>
 	<stddef.h>
 
 

+ 5 - 0
gumbo/gumbo.h

@@ -42,6 +42,11 @@
 #ifndef GUMBO_GUMBO_H_
 #ifndef GUMBO_GUMBO_H_
 #define GUMBO_GUMBO_H_
 #define GUMBO_GUMBO_H_
 
 
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS
+#define fileno _fileno
+#endif
+
 #include <stdbool.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stddef.h>
 
 

+ 15 - 23
gumbo/parser.c

@@ -537,25 +537,6 @@ static bool is_in_static_list(
   return false;
   return false;
 }
 }
 
 
-static void push_template_insertion_mode(
-    GumboParser* parser, GumboInsertionMode mode) {
-  gumbo_vector_add(
-      parser, (void*) mode, &parser->_parser_state->_template_insertion_modes);
-}
-
-static void pop_template_insertion_mode(GumboParser* parser) {
-  gumbo_vector_pop(parser, &parser->_parser_state->_template_insertion_modes);
-}
-
-static GumboInsertionMode get_current_template_insertion_mode(
-    GumboParser* parser) {
-  GumboVector* template_insertion_modes =
-      &parser->_parser_state->_template_insertion_modes;
-  assert(template_insertion_modes->length > 0);
-  return (GumboInsertionMode) template_insertion_modes->data[
-      template_insertion_modes->length - 1];
-}
-
 static void set_insertion_mode(GumboParser* parser, GumboInsertionMode mode) {
 static void set_insertion_mode(GumboParser* parser, GumboInsertionMode mode) {
   parser->_parser_state->_insertion_mode = mode;
   parser->_parser_state->_insertion_mode = mode;
 }
 }
@@ -1735,10 +1716,10 @@ static bool maybe_add_doctype_error(
     GumboParser* parser, const GumboToken* token) {
     GumboParser* parser, const GumboToken* token) {
   const GumboTokenDocType* doctype = &token->v.doc_type;
   const GumboTokenDocType* doctype = &token->v.doc_type;
   bool html_doctype = !strcmp(doctype->name, kDoctypeHtml.data);
   bool html_doctype = !strcmp(doctype->name, kDoctypeHtml.data);
-  if (!html_doctype ||
-      doctype->has_public_identifier ||
-      (doctype->has_system_identifier && !strcmp(
-          doctype->system_identifier, kSystemIdLegacyCompat.data)) ||
+  if ((!html_doctype ||
+       doctype->has_public_identifier ||
+       (doctype->has_system_identifier && !strcmp(
+          doctype->system_identifier, kSystemIdLegacyCompat.data))) &&
       !(html_doctype && (
       !(html_doctype && (
           doctype_matches(doctype, &kPublicIdHtml4_0,
           doctype_matches(doctype, &kPublicIdHtml4_0,
                           &kSystemIdRecHtml4_0, true) ||
                           &kSystemIdRecHtml4_0, true) ||
@@ -2372,6 +2353,13 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
       node = pop_current_node(parser);
       node = pop_current_node(parser);
     } while (node != state->_open_elements.data[1]);
     } while (node != state->_open_elements.data[1]);
 
 
+    // Removing & destroying the body node is going to kill any nodes that have
+    // been added to the list of active formatting elements, and so we should
+    // clear it to prevent a use-after-free if the list of active formatting
+    // elements is reconstructed afterwards.  This may happen if whitespace
+    // follows the </frameset>.
+    clear_active_formatting_elements(parser);
+
     // Remove the body node.  We may want to factor this out into a generic
     // Remove the body node.  We may want to factor this out into a generic
     // helper, but right now this is the only code that needs to do this.
     // helper, but right now this is the only code that needs to do this.
     GumboVector* children = &parser->_output->root->v.element.children;
     GumboVector* children = &parser->_output->root->v.element.children;
@@ -3543,6 +3531,10 @@ static bool handle_after_frameset(GumboParser* parser, GumboToken* token) {
   } else if (tag_is(token, kStartTag, GUMBO_TAG_HTML)) {
   } else if (tag_is(token, kStartTag, GUMBO_TAG_HTML)) {
     return handle_in_body(parser, token);
     return handle_in_body(parser, token);
   } else if (tag_is(token, kEndTag, GUMBO_TAG_HTML)) {
   } else if (tag_is(token, kEndTag, GUMBO_TAG_HTML)) {
+    GumboNode* html = parser->_parser_state->_open_elements.data[0];
+    assert(node_tag_is(html, GUMBO_TAG_HTML));
+    record_end_of_element(
+        parser->_parser_state->_current_token, &html->v.element);
     set_insertion_mode(parser, GUMBO_INSERTION_MODE_AFTER_AFTER_FRAMESET);
     set_insertion_mode(parser, GUMBO_INSERTION_MODE_AFTER_AFTER_FRAMESET);
     return true;
     return true;
   } else if (tag_is(token, kStartTag, GUMBO_TAG_NOFRAMES)) {
   } else if (tag_is(token, kStartTag, GUMBO_TAG_NOFRAMES)) {

+ 6 - 0
gumbo/utf8.c

@@ -208,6 +208,12 @@ void utf8iterator_init(
 }
 }
 
 
 void utf8iterator_next(Utf8Iterator* iter) {
 void utf8iterator_next(Utf8Iterator* iter) {
+  if (iter->_current == -1) {
+    // If we're already at EOF, bail out before advancing anything to avoid
+    // reading past the end of the buffer.  It's easier to catch this case here
+    // than litter the code with lots of individual checks for EOF.
+    return;
+  }
   iter->_start += iter->_width;
   iter->_start += iter->_width;
   // We update positions based on the *last* character read, so that the first
   // We update positions based on the *last* character read, so that the first
   // character following a newline is at column 1 in the next line.
   // character following a newline is at column 1 in the next line.

+ 5 - 1
gumbo/util.h

@@ -19,10 +19,14 @@
 
 
 #ifndef GUMBO_UTIL_H_
 #ifndef GUMBO_UTIL_H_
 #define GUMBO_UTIL_H_
 #define GUMBO_UTIL_H_
-
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS
+#endif
 #include <stdbool.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stddef.h>
 
 
+
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif