Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSS-Fuzz Fixes #1008

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions regression_testing/cases/github-cases/case-1008.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
force-output: yes
1 change: 1 addition & 0 deletions regression_testing/cases/github-cases/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<pre <u
8 changes: 8 additions & 0 deletions regression_testing/cases/github-expects/case-1008.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
26 changes: 26 additions & 0 deletions regression_testing/cases/github-expects/case-1008.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
line 1 column 1 - Warning: <pre> missing '>' for end of tag
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 1 - Warning: inserting implicit <body>
line 1 column 6 - Warning: missing </u>
line 1 column 1 - Warning: missing </pre>
line 1 column 1 - Warning: inserting missing 'title' element
line 1 column 6 - Warning: trimming empty <u>
line 1 column 1 - Warning: trimming empty <pre>
Info: Document content looks like HTML5
Tidy found 8 warnings and 0 errors!

One or more empty elements were present in the source document but
dropped on output. If these elements are necessary or you don't want
this behavior, then consider setting the option "drop-empty-elements"
to no.

About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
Latest HTML specification: https://html.spec.whatwg.org/multipage/
Validate your HTML documents: https://validator.w3.org/nu/
Lobby your company to join the W3C: https://www.w3.org/Consortium

Do you speak a language other than English, or a different variant of
English? Consider helping us to localize HTML Tidy. For details please see
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md
14 changes: 12 additions & 2 deletions src/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -1824,13 +1824,23 @@ void TY_(NormalizeSpaces)(Lexer *lexer, Node *node)
c = (byte) lexer->lexbuf[i];

/* look for UTF-8 multibyte character */
int bytes = 0;
if ( c > 0x7F )
i += TY_(GetUTF8)( lexer->lexbuf + i, &c );
bytes = TY_(GetUTF8)( lexer->lexbuf + i, &c );

if ( c == 160 )
c = ' ';

p = TY_(PutUTF8)(p, c);
/* don't copy replacement char on invalid UTF-8, as it might */
/* be larger than original char and overflow the buffer */
if(bytes > 0) {
p = TY_(PutUTF8)(p, c);
} else {
*p = lexer->lexbuf[i];
p++;
}

i += bytes;
}
node->end = p - lexer->lexbuf;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mappedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static int TIDY_CALL mapped_getByte( void *sourceData )
static Bool TIDY_CALL mapped_eof( void *sourceData )
{
MappedFileSource *data = sourceData;
return ( data->pos >= data->size );
return ( data->pos + (data->iter - data->view) >= data->size );
}

static void TIDY_CALL mapped_ungetByte( void *sourceData, byte ARG_UNUSED(bt) )
Expand Down
3 changes: 2 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4458,9 +4458,10 @@ Node* TY_(ParsePre)( TidyDocImpl* doc, Node *pre, GetTokenMode ARG_UNUSED(mode)
DEBUG_LOG_EXIT;
return NULL;
}

TY_(InlineDup)( doc, NULL ); /* tell lexer to insert inlines if needed */
}

TY_(InlineDup)( doc, NULL ); /* tell lexer to insert inlines if needed */

while ( state != STATE_COMPLETE )
{
Expand Down
2 changes: 1 addition & 1 deletion src/tmbstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void TY_(strrep)(tmbstr buffer, ctmbstr str, ctmbstr rep)
if(p)
{
char buf[1024];
memset(buf,'\0',strlen(buf));
memset(buf,'\0',sizeof(buf));

if(buffer == p)
{
Expand Down