mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
fix: escape HTML in receipt print template to prevent injection
This commit is contained in:
1 parent
c229f40da8
commit
47f9edacfd
1 file changed
+7
-4
@@ -895,6 +895,9 @@ export function AIProviderConfigDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const escapeHtml = (str: string): string =>
|
||||
str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
|
||||
const handlePrintReceipt = (payment: Payment) => {
|
||||
const receiptDate = new Date((payment.completed_at ?? payment.created_at) * 1000);
|
||||
const formattedDate = new Intl.DateTimeFormat('en-US', {
|
||||
@@ -924,7 +927,7 @@ export function AIProviderConfigDialog({
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>${t('receipt')} - ${payment.id}</title>
|
||||
<title>${t('receipt')} - ${escapeHtml(payment.id)}</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@@ -1070,14 +1073,14 @@ export function AIProviderConfigDialog({
|
||||
|
||||
<dl class="details-grid">
|
||||
<dt>${t('receiptNumber')}</dt>
|
||||
<dd>${payment.id}</dd>
|
||||
<dd>${escapeHtml(payment.id)}</dd>
|
||||
<dt>${t('date')}</dt>
|
||||
<dd>${formattedDate} ${formattedTime}</dd>
|
||||
<dt>${t('status')}</dt>
|
||||
<dd>${statusDisplay}</dd>
|
||||
<dd>${escapeHtml(statusDisplay)}</dd>
|
||||
<dt>${t('paymentMethodLabel')}</dt>
|
||||
<dd>${paymentMethodDisplay}</dd>
|
||||
${payment.description ? `<dt>${t('description')}</dt><dd>${payment.description}</dd>` : ''}
|
||||
${payment.description ? `<dt>${t('description')}</dt><dd>${escapeHtml(payment.description)}</dd>` : ''}
|
||||
</dl>
|
||||
|
||||
<hr class="divider" />
|
||||
|
||||
Reference in new issue
Block a user