Skip to content

Encode the text customers enter when it goes into a message - #1091

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/liquid-encode-customer-text
Nov 23, 2026
Merged

KrzysztofPajak merged 1 commit into
developfrom
fix/liquid-encode-customer-text

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Message tokens with text a customer typed were inserted into the e-mail body as they were. A first name with HTML in it became HTML in the e-mail sent to the store owner, and again in the admin panel when that queued e-mail was opened for editing, since the editor shows the body as HTML.

Changes

  • Drops HTML-encode the customer-entered text they expose, as they already did for product names and the purchase order number:
    • LiquidCustomer: e-mail, username, names, gender, date of birth, company, address fields, phone, fax, VAT number, note title
    • LiquidOrder: customer name and e-mail, billing and shipping address fields, VAT number, vendor name and e-mail
    • LiquidMerchandiseReturn: pickup address fields
    • LiquidVendor (name, e-mail, address fields), LiquidVendorReview, LiquidGiftVoucher (sender and recipient), LiquidNewsComment, LiquidBlogComment, LiquidKnowledgebase comment, LiquidNewsLetterSubscription e-mail
    • LiquidAskQuestion, LiquidEmailAFriend, LiquidContactUs: e-mails, names and phone. Their message bodies are already encoded by the callers and are left alone.
  • LiquidExtensions.RenderSubject (new): renders a subject and decodes it, because a subject is plain text. Used by MessageProviderService, CatalogMessageProviderService and CampaignMessageRenderer, so a name like O'Brien does not show as O'Brien.

Notes

  • Formatted values (attribute descriptions, shipping option description) and staff-authored text are unchanged.
  • E-mails already queued keep their body.

Tests

  • LiquidCustomerTests: customer text is encoded; a subject comes out as plain text while the body stays encoded.
  • LiquidOrderTests: billing and shipping text is encoded.
  • Grand.Business.Messages.Tests (171), Grand.Business.Marketing.Tests (162), Grand.Web.Tests (655), Grand.Business.Checkout.Tests (1116) pass.

Message tokens with text a customer typed (names, addresses, e-mails, phone numbers, comments, reviews, gift voucher names) were inserted into the e-mail body as they were. A name with HTML in it became HTML in the e-mail to the store owner, and again in the admin panel when the queued e-mail was opened for editing.

The drops now HTML-encode that text, as they already did for product names and the purchase order number. Text the callers had already encoded (contact enquiries, ask-a-question and e-mail-a-friend messages, notes) is left alone. A subject is plain text, so it is decoded after rendering and a name like O'Brien stays readable there.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@KrzysztofPajak
KrzysztofPajak merged commit 6eef90c into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/liquid-encode-customer-text branch November 25, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants