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

Allow for HTML checking to be loosened on /html/* routes #2000

Open
3 tasks done
Fdawgs opened this issue Feb 7, 2025 · 0 comments
Open
3 tasks done

Allow for HTML checking to be loosened on /html/* routes #2000

Fdawgs opened this issue Feb 7, 2025 · 0 comments
Labels
feature New feature or request

Comments

@Fdawgs
Copy link
Owner

Fdawgs commented Feb 7, 2025

Prerequisites

  • I have written a descriptive title

  • I have searched existing feature requests to ensure it has not already been proposed

  • I agree to follow the Code of Conduct that this project adheres to

Description

A number of NHS trusts have documents stored as HTML that are malformed (missing closing tags etc.) that the underlying html-to-text dependency can still get text out of, but the content type checker parser rejects.

Either a query string param or env variable should/could be used to disable the strict checking in

server.addContentTypeParser(
htmlToTxtPostSchema.consumes,
{ parseAs: "string" },
async (_req, payload) => {
if (payload === "") {
throw server.httpErrors.badRequest("Body cannot be empty");
}
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks the payload is HTML.
*/
if (!isHtml(payload)) {
throw server.httpErrors.unsupportedMediaType();
}
return payload;
}
);

@Fdawgs Fdawgs added the feature New feature or request label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant