summaryrefslogtreecommitdiff
path: root/libs/litehtml/src/gumbo
diff options
context:
space:
mode:
Diffstat (limited to 'libs/litehtml/src/gumbo')
-rw-r--r--libs/litehtml/src/gumbo/CMakeLists.txt8
-rw-r--r--libs/litehtml/src/gumbo/char_ref.c2
-rw-r--r--libs/litehtml/src/gumbo/char_ref.rl2
-rw-r--r--libs/litehtml/src/gumbo/error.c13
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo.h4
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/error.h6
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/tag_enum.h2
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/tag_gperf.h418
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/tag_sizes.h2
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/tag_strings.h2
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/utf8.h2
-rw-r--r--libs/litehtml/src/gumbo/include/gumbo/util.h6
-rw-r--r--libs/litehtml/src/gumbo/parser.c25
-rw-r--r--libs/litehtml/src/gumbo/tag.c7
-rw-r--r--libs/litehtml/src/gumbo/tag.in2
-rw-r--r--libs/litehtml/src/gumbo/tokenizer.c9
-rw-r--r--libs/litehtml/src/gumbo/utf8.c4
-rw-r--r--libs/litehtml/src/gumbo/vector.c2
18 files changed, 375 insertions, 141 deletions
diff --git a/libs/litehtml/src/gumbo/CMakeLists.txt b/libs/litehtml/src/gumbo/CMakeLists.txt
index cd55186a15..7282604893 100644
--- a/libs/litehtml/src/gumbo/CMakeLists.txt
+++ b/libs/litehtml/src/gumbo/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.11)
+cmake_minimum_required(VERSION 3.5)
project(gumbo C)
@@ -46,6 +46,10 @@ set(HEADER_GUMBO
set(PROJECT_LIB_VERSION ${PROJECT_MAJOR}.${PROJECT_MINOR}.0)
set(PROJECT_SO_VERSION ${PROJECT_MAJOR})
+if (MSVC)
+ add_compile_options(/wd4244 /wd4267)
+endif()
+
add_library(${PROJECT_NAME} ${SOURCE_GUMBO})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_LIB_VERSION} SOVERSION ${PROJECT_SO_VERSION})
@@ -54,7 +58,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
PUBLIC_HEADER "${HEADER_GUMBO}"
)
-if(MSVC)
+if (MSVC)
target_include_directories(${PROJECT_NAME} PRIVATE visualc/include)
endif()
diff --git a/libs/litehtml/src/gumbo/char_ref.c b/libs/litehtml/src/gumbo/char_ref.c
index b3c5eccaf3..a1d74fd5df 100644
--- a/libs/litehtml/src/gumbo/char_ref.c
+++ b/libs/litehtml/src/gumbo/char_ref.c
@@ -23009,7 +23009,7 @@ _again:
if (cs >= 7623) {
assert(output->first != kGumboNoChar);
char last_char = *(te - 1);
- ptrdiff_t len = te - start;
+ int len = te - start;
if (last_char == ';') {
bool matched = utf8iterator_maybe_consume_match(input, start, len, true);
assert(matched);
diff --git a/libs/litehtml/src/gumbo/char_ref.rl b/libs/litehtml/src/gumbo/char_ref.rl
index 7c1c410d93..139a4bbd33 100644
--- a/libs/litehtml/src/gumbo/char_ref.rl
+++ b/libs/litehtml/src/gumbo/char_ref.rl
@@ -2493,7 +2493,7 @@ static bool consume_named_ref(
if (cs >= %%{ write first_final; }%%) {
assert(output->first != kGumboNoChar);
char last_char = *(te - 1);
- ptrdiff_t len = te - start;
+ int len = te - start;
if (last_char == ';') {
bool matched = utf8iterator_maybe_consume_match(input, start, len, true);
assert(matched);
diff --git a/libs/litehtml/src/gumbo/error.c b/libs/litehtml/src/gumbo/error.c
index 369e7c11e8..057e89ce29 100644
--- a/libs/litehtml/src/gumbo/error.c
+++ b/libs/litehtml/src/gumbo/error.c
@@ -33,7 +33,7 @@
static int print_message(
GumboParser* parser, GumboStringBuffer* output, const char* format, ...) {
va_list args;
- size_t remaining_capacity = output->capacity - output->length;
+ int remaining_capacity = output->capacity - output->length;
va_start(args, format);
int bytes_written = vsnprintf(
output->data + output->length, remaining_capacity, format, args);
@@ -59,7 +59,7 @@ static int print_message(
}
#endif
- if (bytes_written > remaining_capacity) {
+ if (bytes_written >= remaining_capacity) {
gumbo_string_buffer_reserve(
parser, output->capacity + bytes_written, output);
remaining_capacity = output->capacity - output->length;
@@ -79,7 +79,7 @@ static void print_tag_stack(GumboParser* parser, const GumboParserError* error,
if (i) {
print_message(parser, output, ", ");
}
- GumboTag tag = (GumboTag)(uintptr_t) error->tag_stack.data[i];
+ GumboTag tag = (GumboTag) error->tag_stack.data[i];
print_message(parser, output, gumbo_normalized_tagname(tag));
}
gumbo_string_buffer_append_codepoint(parser, '.', output);
@@ -136,6 +136,13 @@ static const char* find_last_newline(
const char* original_text, const char* error_location) {
assert(error_location >= original_text);
const char* c = error_location;
+ // If the error location itself is a newline then start searching for the
+ // preceding newline one character earlier, if possible. See:
+ // https://github.com/rubys/nokogumbo/commit/bd623555730cdd260f6cec6d7cf990ff297da63d
+ // https://github.com/google/gumbo-parser/pull/371
+ if (*c == '\n' && c != original_text) {
+ c -= 1;
+ }
for (; c != original_text && *c != '\n'; --c) {
// There may be an error at EOF, which would be a nul byte.
assert(*c || c == error_location);
diff --git a/libs/litehtml/src/gumbo/include/gumbo.h b/libs/litehtml/src/gumbo/include/gumbo.h
index 27e6c6c575..f8137cf061 100644
--- a/libs/litehtml/src/gumbo/include/gumbo.h
+++ b/libs/litehtml/src/gumbo/include/gumbo.h
@@ -43,13 +43,9 @@
#define GUMBO_GUMBO_H_
#ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
-#endif
-#ifndef fileno
#define fileno _fileno
#endif
-#endif
#include <stdbool.h>
#include <stddef.h>
diff --git a/libs/litehtml/src/gumbo/include/gumbo/error.h b/libs/litehtml/src/gumbo/include/gumbo/error.h
index 3aa54a6b27..afc998b1fc 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/error.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/error.h
@@ -19,10 +19,8 @@
#ifndef GUMBO_ERROR_H_
#define GUMBO_ERROR_H_
#ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
-#endif
#include <stdint.h>
#include "gumbo.h"
@@ -201,7 +199,7 @@ void gumbo_error_destroy(struct GumboInternalParser* parser, GumboError* error);
// Prints an error to a string. This fills an empty GumboStringBuffer with a
// freshly-allocated buffer containing the error message text. The caller is
// responsible for deleting the buffer. (Note that the buffer is allocated with
-// the allocator specified in the GumboParser ~config and hence should be freed
+// the allocator specified in the GumboParser config and hence should be freed
// by gumbo_parser_deallocate().)
void gumbo_error_to_string(struct GumboInternalParser* parser,
const GumboError* error, GumboStringBuffer* output);
@@ -209,7 +207,7 @@ void gumbo_error_to_string(struct GumboInternalParser* parser,
// Prints a caret diagnostic to a string. This fills an empty GumboStringBuffer
// with a freshly-allocated buffer containing the error message text. The
// caller is responsible for deleting the buffer. (Note that the buffer is
-// allocated with the allocator specified in the GumboParser ~config and hence
+// allocated with the allocator specified in the GumboParser config and hence
// should be freed by gumbo_parser_deallocate().)
void gumbo_caret_diagnostic_to_string(struct GumboInternalParser* parser,
const GumboError* error, const char* source_text,
diff --git a/libs/litehtml/src/gumbo/include/gumbo/tag_enum.h b/libs/litehtml/src/gumbo/include/gumbo/tag_enum.h
index 6d7aeb3d7d..7a33d1e114 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/tag_enum.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/tag_enum.h
@@ -73,6 +73,7 @@ GUMBO_TAG_INS,
GUMBO_TAG_DEL,
GUMBO_TAG_IMAGE,
GUMBO_TAG_IMG,
+GUMBO_TAG_PICTURE,
GUMBO_TAG_IFRAME,
GUMBO_TAG_EMBED,
GUMBO_TAG_OBJECT,
@@ -149,5 +150,6 @@ GUMBO_TAG_MARQUEE,
GUMBO_TAG_MULTICOL,
GUMBO_TAG_NOBR,
GUMBO_TAG_SPACER,
+GUMBO_TAG_DIALOG,
GUMBO_TAG_TT,
GUMBO_TAG_RTC,
diff --git a/libs/litehtml/src/gumbo/include/gumbo/tag_gperf.h b/libs/litehtml/src/gumbo/include/gumbo/tag_gperf.h
index 378eaf958c..525453946f 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/tag_gperf.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/tag_gperf.h
@@ -1,105 +1,321 @@
-static unsigned int tag_hash(
- register const char *str, register unsigned int len) {
- static unsigned short asso_values[] = {296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 6, 4, 3, 1, 1, 0,
- 1, 0, 0, 296, 296, 296, 296, 296, 296, 296, 22, 73, 151, 4, 13, 59, 65, 2,
- 69, 0, 134, 9, 16, 52, 55, 28, 101, 0, 1, 6, 63, 126, 104, 93, 124, 296,
- 296, 296, 296, 296, 296, 296, 22, 73, 151, 4, 13, 59, 65, 2, 69, 0, 134,
- 9, 16, 52, 55, 28, 101, 0, 1, 6, 63, 126, 104, 93, 124, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
- 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296};
+static unsigned int tag_hash(register const char *str, register size_t len)
+{
+ static unsigned short asso_values[] =
+ {
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 30,
+ 27, 27, 9, 6, 3, 6, 6, 3, 274, 274,
+ 274, 274, 274, 274, 274, 78, 3, 171, 12, 30,
+ 39, 129, 12, 105, 24, 156, 9, 51, 60, 87,
+ 12, 96, 3, 6, 18, 75, 99, 96, 36, 123,
+ 274, 274, 274, 274, 274, 274, 274, 78, 3, 171,
+ 12, 30, 39, 129, 12, 105, 24, 156, 9, 51,
+ 60, 87, 12, 96, 3, 6, 18, 75, 99, 96,
+ 36, 123, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274,
+ 274, 274, 274, 274, 274, 274, 274, 274, 274
+ };
register unsigned int hval = len;
- switch (hval) {
- default:
- hval += asso_values[(unsigned char) str[1] + 3];
- /*FALLTHROUGH*/
- case 1:
- hval += asso_values[(unsigned char) str[0]];
- break;
- }
- return hval + asso_values[(unsigned char) str[len - 1]];
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[1]+3];
+ /*FALLTHROUGH*/
+ case 1:
+ hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
}
-static const unsigned char kGumboTagMap[] = {GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_S, GUMBO_TAG_H6, GUMBO_TAG_H5, GUMBO_TAG_H4,
- GUMBO_TAG_H3, GUMBO_TAG_SPACER, GUMBO_TAG_H2, GUMBO_TAG_HEADER,
- GUMBO_TAG_H1, GUMBO_TAG_HEAD, GUMBO_TAG_LAST, GUMBO_TAG_DETAILS,
- GUMBO_TAG_SELECT, GUMBO_TAG_DIR, GUMBO_TAG_LAST, GUMBO_TAG_DEL,
- GUMBO_TAG_LAST, GUMBO_TAG_SOURCE, GUMBO_TAG_LEGEND, GUMBO_TAG_DATALIST,
- GUMBO_TAG_METER, GUMBO_TAG_MGLYPH, GUMBO_TAG_LAST, GUMBO_TAG_MATH,
- GUMBO_TAG_LABEL, GUMBO_TAG_TABLE, GUMBO_TAG_TEMPLATE, GUMBO_TAG_LAST,
- GUMBO_TAG_RP, GUMBO_TAG_TIME, GUMBO_TAG_TITLE, GUMBO_TAG_DATA,
- GUMBO_TAG_APPLET, GUMBO_TAG_HGROUP, GUMBO_TAG_SAMP, GUMBO_TAG_TEXTAREA,
- GUMBO_TAG_ABBR, GUMBO_TAG_MARQUEE, GUMBO_TAG_LAST, GUMBO_TAG_MENUITEM,
- GUMBO_TAG_SMALL, GUMBO_TAG_META, GUMBO_TAG_A, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_EMBED,
- GUMBO_TAG_MAP, GUMBO_TAG_LAST, GUMBO_TAG_PARAM, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_NOBR, GUMBO_TAG_P, GUMBO_TAG_SPAN, GUMBO_TAG_EM,
- GUMBO_TAG_LAST, GUMBO_TAG_NOFRAMES, GUMBO_TAG_SECTION, GUMBO_TAG_NOEMBED,
- GUMBO_TAG_NEXTID, GUMBO_TAG_FOOTER, GUMBO_TAG_NOSCRIPT, GUMBO_TAG_HR,
- GUMBO_TAG_LAST, GUMBO_TAG_FONT, GUMBO_TAG_DL, GUMBO_TAG_TR,
- GUMBO_TAG_SCRIPT, GUMBO_TAG_MO, GUMBO_TAG_LAST, GUMBO_TAG_DD,
- GUMBO_TAG_MAIN, GUMBO_TAG_TD, GUMBO_TAG_FOREIGNOBJECT, GUMBO_TAG_FORM,
- GUMBO_TAG_OBJECT, GUMBO_TAG_LAST, GUMBO_TAG_FIELDSET, GUMBO_TAG_LAST,
- GUMBO_TAG_BGSOUND, GUMBO_TAG_MENU, GUMBO_TAG_TFOOT, GUMBO_TAG_FIGURE,
- GUMBO_TAG_RB, GUMBO_TAG_LI, GUMBO_TAG_LISTING, GUMBO_TAG_BASEFONT,
- GUMBO_TAG_OPTGROUP, GUMBO_TAG_LAST, GUMBO_TAG_BASE, GUMBO_TAG_ADDRESS,
- GUMBO_TAG_MI, GUMBO_TAG_LAST, GUMBO_TAG_PLAINTEXT, GUMBO_TAG_LAST,
- GUMBO_TAG_PROGRESS, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_ACRONYM, GUMBO_TAG_ARTICLE, GUMBO_TAG_LAST, GUMBO_TAG_PRE,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_AREA,
- GUMBO_TAG_RT, GUMBO_TAG_LAST, GUMBO_TAG_OPTION, GUMBO_TAG_IMAGE,
- GUMBO_TAG_DT, GUMBO_TAG_LAST, GUMBO_TAG_TT, GUMBO_TAG_HTML, GUMBO_TAG_WBR,
- GUMBO_TAG_OL, GUMBO_TAG_LAST, GUMBO_TAG_STYLE, GUMBO_TAG_STRIKE,
- GUMBO_TAG_SUP, GUMBO_TAG_MULTICOL, GUMBO_TAG_U, GUMBO_TAG_DFN, GUMBO_TAG_UL,
- GUMBO_TAG_FIGCAPTION, GUMBO_TAG_MTEXT, GUMBO_TAG_LAST, GUMBO_TAG_VAR,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_FRAMESET, GUMBO_TAG_LAST,
- GUMBO_TAG_BR, GUMBO_TAG_I, GUMBO_TAG_FRAME, GUMBO_TAG_LAST, GUMBO_TAG_DIV,
- GUMBO_TAG_LAST, GUMBO_TAG_TH, GUMBO_TAG_MS, GUMBO_TAG_ANNOTATION_XML,
- GUMBO_TAG_B, GUMBO_TAG_TBODY, GUMBO_TAG_THEAD, GUMBO_TAG_BIG,
- GUMBO_TAG_BLOCKQUOTE, GUMBO_TAG_XMP, GUMBO_TAG_LAST, GUMBO_TAG_KBD,
- GUMBO_TAG_LAST, GUMBO_TAG_LINK, GUMBO_TAG_IFRAME, GUMBO_TAG_MARK,
- GUMBO_TAG_CENTER, GUMBO_TAG_OUTPUT, GUMBO_TAG_DESC, GUMBO_TAG_CANVAS,
- GUMBO_TAG_COL, GUMBO_TAG_MALIGNMARK, GUMBO_TAG_IMG, GUMBO_TAG_ASIDE,
- GUMBO_TAG_LAST, GUMBO_TAG_CODE, GUMBO_TAG_LAST, GUMBO_TAG_SUB, GUMBO_TAG_MN,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_INS, GUMBO_TAG_AUDIO,
- GUMBO_TAG_STRONG, GUMBO_TAG_CITE, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_INPUT, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_NAV, GUMBO_TAG_LAST, GUMBO_TAG_COLGROUP,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_SVG, GUMBO_TAG_KEYGEN, GUMBO_TAG_VIDEO,
- GUMBO_TAG_BDO, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_BODY, GUMBO_TAG_LAST, GUMBO_TAG_Q, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_TRACK,
- GUMBO_TAG_LAST, GUMBO_TAG_BDI, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_CAPTION, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_RUBY, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_BUTTON,
- GUMBO_TAG_SUMMARY, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_RTC, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_BLINK, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_LAST,
- GUMBO_TAG_LAST, GUMBO_TAG_LAST, GUMBO_TAG_ISINDEX};
+static const unsigned char kGumboTagMap[] = {
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_B,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_S,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_H6,
+ GUMBO_TAG_SPACER,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_RP,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_P,
+ GUMBO_TAG_H5,
+ GUMBO_TAG_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LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_SVG,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_LAST,
+ GUMBO_TAG_RTC
+};
diff --git a/libs/litehtml/src/gumbo/include/gumbo/tag_sizes.h b/libs/litehtml/src/gumbo/include/gumbo/tag_sizes.h
index 7c92de073b..5b93c22fa2 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/tag_sizes.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/tag_sizes.h
@@ -1,4 +1,4 @@
// Generated via `gentags.py src/tag.in`.
// Do not edit; edit src/tag.in instead.
// clang-format off
-4, 4, 5, 4, 4, 4, 5, 6, 8, 8, 4, 7, 7, 3, 5, 2, 2, 2, 2, 2, 2, 6, 6, 6, 7, 1, 2, 3, 10, 2, 2, 2, 2, 2, 2, 6, 10, 4, 3, 1, 2, 6, 5, 1, 4, 1, 3, 4, 4, 4, 4, 3, 4, 3, 3, 3, 1, 1, 1, 4, 4, 2, 2, 3, 3, 4, 2, 3, 3, 3, 5, 3, 6, 5, 6, 5, 5, 5, 6, 5, 6, 3, 4, 4, 2, 2, 2, 2, 5, 6, 10, 14, 3, 13, 4, 5, 7, 8, 3, 5, 5, 5, 2, 2, 2, 4, 8, 6, 5, 5, 6, 6, 8, 8, 6, 8, 6, 6, 8, 5, 7, 7, 4, 8, 6, 7, 7, 3, 5, 8, 8, 7, 7, 3, 6, 7, 9, 2, 6, 8, 3, 5, 6, 4, 7, 8, 4, 6, 2, 3, \ No newline at end of file
+4, 4, 5, 4, 4, 4, 5, 6, 8, 8, 4, 7, 7, 3, 5, 2, 2, 2, 2, 2, 2, 6, 6, 6, 7, 1, 2, 3, 10, 2, 2, 2, 2, 2, 2, 6, 10, 4, 3, 1, 2, 6, 5, 1, 4, 1, 3, 4, 4, 4, 4, 3, 4, 3, 3, 3, 1, 1, 1, 4, 4, 2, 2, 3, 3, 4, 2, 3, 3, 3, 5, 3, 7, 6, 5, 6, 5, 5, 5, 6, 5, 6, 3, 4, 4, 2, 2, 2, 2, 5, 6, 10, 14, 3, 13, 4, 5, 7, 8, 3, 5, 5, 5, 2, 2, 2, 4, 8, 6, 5, 5, 6, 6, 8, 8, 6, 8, 6, 6, 8, 5, 7, 7, 4, 8, 6, 7, 7, 3, 5, 8, 8, 7, 7, 3, 6, 7, 9, 2, 6, 8, 3, 5, 6, 4, 7, 8, 4, 6, 6, 2, 3, \ No newline at end of file
diff --git a/libs/litehtml/src/gumbo/include/gumbo/tag_strings.h b/libs/litehtml/src/gumbo/include/gumbo/tag_strings.h
index 6540e2e6ba..03d793c05d 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/tag_strings.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/tag_strings.h
@@ -73,6 +73,7 @@
"del",
"image",
"img",
+"picture",
"iframe",
"embed",
"object",
@@ -149,5 +150,6 @@
"multicol",
"nobr",
"spacer",
+"dialog",
"tt",
"rtc",
diff --git a/libs/litehtml/src/gumbo/include/gumbo/utf8.h b/libs/litehtml/src/gumbo/include/gumbo/utf8.h
index ee852abfba..bd31a781ee 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/utf8.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/utf8.h
@@ -62,7 +62,7 @@ typedef struct GumboInternalUtf8Iterator {
int _current;
// The width in bytes of the current code point.
- ptrdiff_t _width;
+ int _width;
// The SourcePosition for the current location.
GumboSourcePosition _pos;
diff --git a/libs/litehtml/src/gumbo/include/gumbo/util.h b/libs/litehtml/src/gumbo/include/gumbo/util.h
index 98a7d1c466..6ad65649e6 100644
--- a/libs/litehtml/src/gumbo/include/gumbo/util.h
+++ b/libs/litehtml/src/gumbo/include/gumbo/util.h
@@ -20,10 +20,8 @@
#ifndef GUMBO_UTIL_H_
#define GUMBO_UTIL_H_
#ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
-#endif
#include <stdbool.h>
#include <stddef.h>
@@ -43,12 +41,12 @@ struct GumboInternalParser;
char* gumbo_copy_stringz(struct GumboInternalParser* parser, const char* str);
// Allocate a chunk of memory, using the allocator specified in the Parser's
-// ~config options.
+// config options.
void* gumbo_parser_allocate(
struct GumboInternalParser* parser, size_t num_bytes);
// Deallocate a chunk of memory, using the deallocator specified in the Parser's
-// ~config options.
+// config options.
void gumbo_parser_deallocate(struct GumboInternalParser* parser, void* ptr);
// Debug wrapper for printf, to make it easier to turn off debugging info when
diff --git a/libs/litehtml/src/gumbo/parser.c b/libs/litehtml/src/gumbo/parser.c
index 653fd85acc..968fcc0f41 100644
--- a/libs/litehtml/src/gumbo/parser.c
+++ b/libs/litehtml/src/gumbo/parser.c
@@ -45,7 +45,7 @@ typedef char gumbo_tagset[GUMBO_TAG_LAST];
#define TAG_MATHML(tag) [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_MATHML)
#define TAGSET_INCLUDES(tagset, namespace, tag) \
- (tag < GUMBO_TAG_LAST && tagset[(int) tag] == (1 << (int) namespace))
+ (tag < GUMBO_TAG_LAST && tagset[(int) tag] & (1 << (int) namespace))
// selected forward declarations as it is getting hard to find
// an appropriate order
@@ -572,6 +572,10 @@ static GumboInsertionMode get_appropriate_insertion_mode(
}
assert(node->type == GUMBO_NODE_ELEMENT || node->type == GUMBO_NODE_TEMPLATE);
+ if (node->v.element.tag_namespace != GUMBO_NAMESPACE_HTML)
+ return is_last ?
+ GUMBO_INSERTION_MODE_IN_BODY : GUMBO_INSERTION_MODE_INITIAL;
+
switch (node->v.element.tag) {
case GUMBO_TAG_SELECT: {
if (is_last) {
@@ -812,7 +816,7 @@ InsertionLocation get_appropriate_insertion_location(
GumboNode* last_table = open_elements->data[last_table_index];
if (last_table->parent != NULL) {
retval.target = last_table->parent;
- retval.index = (int)last_table->index_within_parent;
+ retval.index = last_table->index_within_parent;
return retval;
}
@@ -2512,8 +2516,8 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
return success;
} else if (tag_in(token, kStartTag,
(gumbo_tagset){TAG(ADDRESS), TAG(ARTICLE), TAG(ASIDE),
- TAG(BLOCKQUOTE), TAG(CENTER), TAG(DETAILS), TAG(DIR),
- TAG(DIV), TAG(DL), TAG(FIELDSET), TAG(FIGCAPTION),
+ TAG(BLOCKQUOTE), TAG(CENTER), TAG(DETAILS), TAG(DIALOG),
+ TAG(DIR), TAG(DIV), TAG(DL), TAG(FIELDSET), TAG(FIGCAPTION),
TAG(FIGURE), TAG(FOOTER), TAG(HEADER), TAG(HGROUP),
TAG(MENU), TAG(MAIN), TAG(NAV), TAG(OL), TAG(P),
TAG(SECTION), TAG(SUMMARY), TAG(UL)})) {
@@ -2582,7 +2586,7 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
} else if (tag_in(token, kEndTag,
(gumbo_tagset){TAG(ADDRESS), TAG(ARTICLE), TAG(ASIDE),
TAG(BLOCKQUOTE), TAG(BUTTON), TAG(CENTER), TAG(DETAILS),
- TAG(DIR), TAG(DIV), TAG(DL), TAG(FIELDSET),
+ TAG(DIALOG), TAG(DIR), TAG(DIV), TAG(DL), TAG(FIELDSET),
TAG(FIGCAPTION), TAG(FIGURE), TAG(FOOTER), TAG(HEADER),
TAG(HGROUP), TAG(LISTING), TAG(MAIN), TAG(MENU), TAG(NAV),
TAG(OL), TAG(PRE), TAG(SECTION), TAG(SUMMARY), TAG(UL)})) {
@@ -2613,7 +2617,7 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
return success;
} else {
bool result = true;
- const GumboNode* node = state->_form_element;
+ GumboNode* node = state->_form_element;
assert(!node || node->type == GUMBO_NODE_ELEMENT);
state->_form_element = NULL;
if (!node || !has_node_in_scope(parser, node)) {
@@ -2622,10 +2626,15 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
ignore_token(parser);
return false;
}
+ // Since we remove the form node without popping, we need to make sure
+ // that we flush any text nodes at the end of the form.
+ maybe_flush_text_node_buffer(parser);
// This differs from implicitly_close_tags because we remove *only* the
// <form> element; other nodes are left in scope.
generate_implied_end_tags(parser, GUMBO_TAG_LAST);
- if (get_current_node(parser) != node) {
+ if (get_current_node(parser) == node) {
+ record_end_of_element(token, &node->v.element);
+ } else {
parser_add_parse_error(parser, token);
result = false;
}
@@ -2845,7 +2854,7 @@ static bool handle_in_body(GumboParser* parser, GumboToken* token) {
text_state->_start_position = token->position;
text_state->_type = GUMBO_NODE_TEXT;
if (prompt_attr) {
- size_t prompt_attr_length = strlen(prompt_attr->value);
+ int prompt_attr_length = strlen(prompt_attr->value);
gumbo_string_buffer_destroy(parser, &text_state->_buffer);
text_state->_buffer.data = gumbo_copy_stringz(parser, prompt_attr->value);
text_state->_buffer.length = prompt_attr_length;
diff --git a/libs/litehtml/src/gumbo/tag.c b/libs/litehtml/src/gumbo/tag.c
index a394c0a677..85d58d28f0 100644
--- a/libs/litehtml/src/gumbo/tag.c
+++ b/libs/litehtml/src/gumbo/tag.c
@@ -41,7 +41,6 @@ void gumbo_tag_from_original_text(GumboStringPiece* text) {
if (text->data == NULL) {
return;
}
-
assert(text->length >= 2);
assert(text->data[0] == '<');
assert(text->data[text->length - 1] == '>');
@@ -54,10 +53,10 @@ void gumbo_tag_from_original_text(GumboStringPiece* text) {
// Start tag.
text->data += 1; // Move past <
text->length -= 2;
- // strnchr is apparently not a standard C library function, so I loop
// explicitly looking for whitespace or other illegal tag characters.
+ // see https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state
for (const char* c = text->data; c != text->data + text->length; ++c) {
- if (isspace(*c) || *c == '/') {
+ if (*c == ' ' || *c == '\t' || *c == '\n' || *c == '\f' || *c == '/') {
text->length = c - text->data;
break;
}
@@ -91,5 +90,5 @@ GumboTag gumbo_tagn_enum(const char* tagname, unsigned int length) {
}
GumboTag gumbo_tag_enum(const char* tagname) {
- return gumbo_tagn_enum(tagname, (unsigned)strlen(tagname));
+ return gumbo_tagn_enum(tagname, strlen(tagname));
}
diff --git a/libs/litehtml/src/gumbo/tag.in b/libs/litehtml/src/gumbo/tag.in
index 4c25264857..5716462914 100644
--- a/libs/litehtml/src/gumbo/tag.in
+++ b/libs/litehtml/src/gumbo/tag.in
@@ -70,6 +70,7 @@ ins
del
image
img
+picture
iframe
embed
object
@@ -146,5 +147,6 @@ marquee
multicol
nobr
spacer
+dialog
tt
rtc
diff --git a/libs/litehtml/src/gumbo/tokenizer.c b/libs/litehtml/src/gumbo/tokenizer.c
index 0d0ea0f241..71b5d32ad4 100644
--- a/libs/litehtml/src/gumbo/tokenizer.c
+++ b/libs/litehtml/src/gumbo/tokenizer.c
@@ -377,7 +377,7 @@ static bool temporary_buffer_equals(GumboParser* parser, const char* text) {
// TODO(jdtang): See if the extra strlen is a performance problem, and replace
// it with an explicit sizeof(literal) if necessary. I don't think it will
// be, as this is only used in a couple of rare states.
- size_t text_len = strlen(text);
+ int text_len = strlen(text);
return text_len == buffer->length &&
memcmp(buffer->data, text, text_len) == 0;
}
@@ -726,7 +726,8 @@ static void copy_over_original_tag_text(GumboParser* parser,
original_text->data = tag_state->_original_text;
original_text->length = utf8iterator_get_char_pointer(&tokenizer->_input) -
tag_state->_original_text;
- if (original_text->data[original_text->length - 1] == '\r') {
+ if (original_text->length > 0
+ && original_text->data[original_text->length - 1] == '\r') {
// Since \r is skipped by the UTF-8 iterator, it can sometimes end up
// appended to the end of original text even when it's really the first part
// of the next character. If we detect this situation, shrink the length of
@@ -751,7 +752,7 @@ static void finish_tag_name(GumboParser* parser) {
GumboTagState* tag_state = &tokenizer->_tag_state;
tag_state->_tag =
- gumbo_tagn_enum(tag_state->_buffer.data, (unsigned)tag_state->_buffer.length);
+ gumbo_tagn_enum(tag_state->_buffer.data, tag_state->_buffer.length);
reinitialize_tag_buffer(parser);
}
@@ -839,7 +840,7 @@ static bool is_appropriate_end_tag(GumboParser* parser) {
assert(!tag_state->_is_start_tag);
return tag_state->_last_start_tag != GUMBO_TAG_LAST &&
tag_state->_last_start_tag == gumbo_tagn_enum(tag_state->_buffer.data,
- (unsigned)tag_state->_buffer.length);
+ tag_state->_buffer.length);
}
void gumbo_tokenizer_state_init(
diff --git a/libs/litehtml/src/gumbo/utf8.c b/libs/litehtml/src/gumbo/utf8.c
index ad73cefa6a..fdd6f8377c 100644
--- a/libs/litehtml/src/gumbo/utf8.c
+++ b/libs/litehtml/src/gumbo/utf8.c
@@ -137,7 +137,7 @@ static void read_char(Utf8Iterator* iter) {
for (const char* c = iter->_start; c < iter->_end; ++c) {
decode(&state, &code_point, (uint32_t)(unsigned char) (*c));
if (state == UTF8_ACCEPT) {
- iter->_width = (int)(c - iter->_start + 1);
+ iter->_width = c - iter->_start + 1;
// This is the special handling for carriage returns that is mandated by
// the HTML5 spec. Since we're looking for particular 7-bit literal
// characters, we operate in terms of chars and only need a check for iter
@@ -181,7 +181,7 @@ static void read_char(Utf8Iterator* iter) {
}
static void update_position(Utf8Iterator* iter) {
- iter->_pos.offset += (int)iter->_width;
+ iter->_pos.offset += iter->_width;
if (iter->_current == '\n') {
++iter->_pos.line;
iter->_pos.column = 1;
diff --git a/libs/litehtml/src/gumbo/vector.c b/libs/litehtml/src/gumbo/vector.c
index b9aa474e67..51758dfe03 100644
--- a/libs/litehtml/src/gumbo/vector.c
+++ b/libs/litehtml/src/gumbo/vector.c
@@ -30,7 +30,7 @@ const GumboVector kGumboEmptyVector = {NULL, 0, 0};
void gumbo_vector_init(struct GumboInternalParser* parser,
size_t initial_capacity, GumboVector* vector) {
vector->length = 0;
- vector->capacity = (unsigned)initial_capacity;
+ vector->capacity = initial_capacity;
if (initial_capacity > 0) {
vector->data =
gumbo_parser_allocate(parser, sizeof(void*) * initial_capacity);