Skip to content

Commit

Permalink
fix: Add ampersand to unescapeHTML list
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jan 8, 2024
1 parent 59d016a commit 71c1a94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api.planx.uk/modules/send/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function logPaymentStatus({
}

// tmp explicit error handling
function reportError(obj: object) {
export function reportError(obj: object) {
if (airbrake) {
airbrake.notify(obj);
return;
Expand Down
10 changes: 4 additions & 6 deletions api.planx.uk/modules/webhooks/service/validateInput/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isObject } from "lodash";
import { JSDOM } from "jsdom";
import createDOMPurify from "dompurify";
import { userContext } from "../../../auth/middleware";
import { reportError } from "../../../send/utils/helpers";

// Setup JSDOM and DOMPurify
const window = new JSDOM("").window;
Expand Down Expand Up @@ -57,11 +57,8 @@ export const isCleanHTML = (input: unknown): boolean => {
* Logging this should help us identify and resolve these
*/
const logUncleanHTMLError = (input: string, cleanHTML: string) => {
const userId = userContext.getStore()?.user.sub;

console.error({
reportError({
message: `Warning: Unclean HTML submitted!`,
userId,
input,
cleanHTML,
});
Expand All @@ -71,4 +68,5 @@ const unescapeHTML = (input: string): string =>
input
.replace(/"/gi, '"')
.replace(/'/gi, "'")
.replace(/ /gi, " ");
.replace(/ /gi, " ")
.replace(/&/gi, "&");

0 comments on commit 71c1a94

Please sign in to comment.