-
Notifications
You must be signed in to change notification settings - Fork 640
Fix handling of truncated legacy errorpage %codes #2411
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -958,7 +958,8 @@ ErrorState::compileLegacyCode(Build &build) | |
|
|
||
| const auto &building_deny_info_url = build.building_deny_info_url; // a change reduction hack | ||
|
|
||
| const auto letter = build.input[1]; | ||
| Assure(*build.input == '%'); | ||
| const auto letter = build.input[1]; // may be the terminating NUL | ||
|
|
||
| switch (letter) { | ||
|
|
||
|
|
@@ -1261,13 +1262,25 @@ ErrorState::compileLegacyCode(Build &build) | |
| p = "%"; | ||
| break; | ||
|
|
||
| case '\0': | ||
| // XXX: Partially duplicates error handling code of the `default:` case. | ||
| // TODO: Refactor bypassBuildErrorXXX() to accept `build` and determine the source of the error. | ||
| if (building_deny_info_url) | ||
| bypassBuildErrorXXX("Bare % at the end of deny_info", build.input); | ||
| else | ||
| bypassBuildErrorXXX("Bare % at the end of error page", build.input); | ||
| p = "%"; | ||
| do_quote = 0; | ||
| break; | ||
|
|
||
| default: | ||
| if (building_deny_info_url) | ||
| bypassBuildErrorXXX("Unsupported deny_info %code", build.input); | ||
| else if (letter != ';') | ||
| bypassBuildErrorXXX("Unsupported error page %code", build.input); | ||
| // else too many "font-size: 100%;" template errors to report | ||
|
|
||
| Assure(build.input[1]); | ||
| mb.append(build.input, 2); | ||
| do_quote = 0; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not disable quoting in this case IMO, but that is a different problem that has a much smaller impact and that is best addressed when refactoring this code to fully address other related problems. |
||
| break; | ||
|
|
@@ -1278,7 +1291,8 @@ ErrorState::compileLegacyCode(Build &build) | |
|
|
||
| assert(p); | ||
|
|
||
| debugs(4, 3, "%" << letter << " --> '" << p << "'" ); | ||
| // TODO: Add an I/O manipulator to report non-printable chars better. | ||
| debugs(4, 3, "%" << (letter ? letter : '?') << " --> '" << p << "'" ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this hack, debugging line is truncated at the first |
||
|
|
||
| if (do_quote) | ||
| p = html_quote(p); | ||
|
|
@@ -1288,7 +1302,9 @@ ErrorState::compileLegacyCode(Build &build) | |
|
|
||
| // TODO: Optimize by replacing mb with direct build.output usage. | ||
| build.output.append(p, strlen(p)); | ||
| build.input += 2; | ||
| ++build.input; // skip the parsed % character | ||
| if (letter) | ||
| ++build.input; // when it was present, skip the parsed letter after % | ||
| } | ||
|
|
||
| void | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not addressing this XXX/TODO in this PR to provide a surgical fix that is easier to backport.