Improve redbean docs (#249)

- Add Location to ProgramHeader exclusions
- Add ProgramHeader documentation
- Update ProgramRedirect to check location validity
This commit is contained in:
Paul Kulchenko 2021-08-19 09:34:50 -07:00 committed by GitHub
parent a63b147a93
commit 7341336b1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 15 deletions

View file

@ -750,6 +750,12 @@ static void ProgramRedirect(int code, const char *sp, size_t sn, const char *dp,
fprintf(stderr, "error: unsupported redirect code %d\n", code);
exit(1);
}
if (!(FreeLater(EncodeHttpHeaderValue(dp, dn, 0)))) {
fprintf(stderr, "error: invalid location %s\n", dp);
exit(1);
}
r.code = code;
r.path.s = sp;
r.path.n = sn;
@ -928,6 +934,7 @@ static void ProgramHeader(const char *s) {
case kHttpContentLength:
case kHttpContentEncoding:
case kHttpContentRange:
case kHttpLocation:
fprintf(stderr, "error: can't program header: %`'s\n", s);
exit(1);
case kHttpServer: