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

fix limitation for size of data:*:base64 images and max length of the html input line #454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shaeto
Copy link

@Shaeto Shaeto commented Nov 13, 2021

  1. currently maximum size of <img ... src='data:...:base64.....' ..> image is ~7k
  2. maximum length of input line for input html document is 10240 (limited by code in htmllib.cxx)

this patch removes these limitations

test command is:

cat ./test.html | htmldoc --webpage -t pdf - > test.pdf

test.html is attached

test.html.zip

Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK wth allowing larger strings, but I don't want them to be unbounded - HTMLDOC is used to provide live conversions on web servers.

@@ -420,18 +420,22 @@ file_find_check(const char *filename) /* I - File or URL */

if ((data = strstr(filename, ";base64,")) != NULL)
{
len = sizeof(buffer);
len = strlen(filename);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have some limits in place to avoid out-of-control memory allocations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree... actually it must be limited in htmllib.cxx line(s) reader

10240 is definitely too small, limit it to something x100 times bigger ? is not big problem for server application ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might work, will run the numbers...

@@ -15,7 +15,7 @@
#include "htmldoc.h"
#include "http.h"
#include <ctype.h>

#include <string>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and while I do use C++ in HTMLDOC, I've avoided pulling in the standard C++ library since it seems to change with every major OS release on multiple platforms...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought this file was renamed to .cxx keeping in mind idea write c++ code :)

imho std::string is very very stable, it can be replaced by std::vector or do you suggest to implement custom byte vector ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libstdc++ has changed in incompatible ways 6 times in the last ~20 years, making it very hard to provide binaries of HTMLDOC that depend on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants