-
Notifications
You must be signed in to change notification settings - Fork 429
TidyDoctypeMode option documentation missing #472
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
Comments
TidyDoctypeMode
option documentation missing
@ralfjunker wow, you raise an interesting question or 2, which leads to a potential bug... thanks... As far as I can see, there is no actual option, And there should be a fix to avoid that crash... In the Perhaps the To try to explain more. This particular
And as @jidanni points out in #435, all this is not well explained in - http://api.html-tidy.org/tidy/quickref_5.2.0.html#doctype! Nor, as also pointed out, completely implemented, in that a user string type seems ignored... I think because of this dual option type the actual enumerated int is kept in the So first, the simple bug I see. If a person enters an option diff --git a/src/config.c b/src/config.c
index ddb677c..343b337 100644
--- a/src/config.c
+++ b/src/config.c
@@ -924,8 +924,12 @@ Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optval
const TidyOptionImpl* option = option_defs + optId;
Bool status = ( optId < N_TIDY_OPTIONS && optval != NULL );
- if ( !status )
- TY_(ReportBadArgument)( doc, option->name );
+ if (!status || !option->parser) {
+ /* Issue #472 - report a 'bad' option name,
+ *or* if the option has a NULL parser.
+ TODO: Add error message for a NULL parser. */
+ TY_(ReportBadArgument)(doc, option->name);
+ }
else
{
TidyBuffer inbuf; /* Set up input source */ And note, the actual error message needs to be added for this NULL parser case. One could argue that they should not be using an option not documented - just what they found in the source. But on the other hand tidy should not crash in And further note, this area of the config code is also related to #468, where I am waiting for some user's with non-ascii file name test the fix in branch Need to explore more on this, and would appreciate any assistance, including the documentation issue, and implementation, mentioned in #435... thanks... |
Interesting findings. However, Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optval )
{
const TidyOptionImpl* option;
Bool status = (
optId < N_TIDY_OPTIONS &&
(option = option_defs + optId)->parser &&
optval != NULL );
if ( !status )
TY_(ReportBadArgument)( doc, option->name );
else
{
TidyBuffer inbuf; /* Set up input source */ Note that the |
@ralfjunker, yes I think your patch reads better in that is also preserves the return failure... Also see #473 for mention of another option, Still to get to testing this... thanks... |
Please test #509 so we can close. |
#509 works fine, but Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optval )
{
const TidyOptionImpl* option = NULL;
- enum { sizeBuf = 11 };
- char buffer[sizeBuf];
/* #472: fail status if there is a NULL parser. @ralfjunker */
Bool status = ( optId < N_TIDY_OPTIONS
&& (option = option_defs + optId)->parser
&& optval != NULL );
if ( !status )
if ( option )
TY_(ReportBadArgument)(doc, option->name);
else
{
/* If optId < N_TIDY_OPTIONS then option remains unassigned,
and we have to fall back to an ugly error message. */
- TY_(tmbsnprintf(buffer, sizeBuf, "%u", optId));
- TY_(ReportUnknownOption(doc, buffer));
+ char buf[11];
+ TY_(tmbsnprintf(buf, sizeof(buf), "%u", optId));
+ TY_(ReportUnknownOption(doc, buf));
} |
@ralfjunker, that's actually how I'd prefer to do it, but I see that Tidy's existing code uses the enum pretty pervasively elsewhere. And we still support K&R as far as I can tell (or at the latest, C90), and I always have a hard time remembering where I can declare new variables without breaking other people's compilers. Refresh my memory, and I'll clean it up ;-) |
Reminder to self: C89, so no issues with context. Updated per @ralfjunker's suggestion, merged, and closed. |
The
TidyDoctypeMode
option is not documented. Documentation is missing both online at http://api.html-tidy.org/tidy/quickref_5.2.0.html#doctype as well as built into libtidy.There is just a short comment in
tidyenum.h
which asks to "See doctype property". Unfortunately,TidyDoctype
does not mentionTidyDoctypeMode
.In particular,
Could you please add the missing
TidyDoctypeMode
documentation?The text was updated successfully, but these errors were encountered: