From 24f9e1122111a73fbd49c46e0f137ddb0f5d45eb Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 22 Nov 2021 11:49:11 +0100 Subject: Fix image description unnecessarily html-escaping innocent characters (#321) * implement SanitizeCaption function * tidy up text test setup --- internal/processing/media/create.go | 2 +- internal/processing/media/update.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/processing') diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go index 0783bfae8..adc44a4ea 100644 --- a/internal/processing/media/create.go +++ b/internal/processing/media/create.go @@ -56,7 +56,7 @@ func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, form CreatedAt: time.Now(), UpdatedAt: time.Now(), AccountID: account.ID, - Description: text.RemoveHTML(form.Description), + Description: text.SanitizeCaption(form.Description), FileMeta: gtsmodel.FileMeta{ Focus: gtsmodel.Focus{ X: focusx, diff --git a/internal/processing/media/update.go b/internal/processing/media/update.go index b3455bc91..42e050121 100644 --- a/internal/processing/media/update.go +++ b/internal/processing/media/update.go @@ -45,7 +45,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, media } if form.Description != nil { - attachment.Description = text.RemoveHTML(*form.Description) + attachment.Description = text.SanitizeCaption(*form.Description) if err := p.db.UpdateByPrimaryKey(ctx, attachment); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("database error updating description: %s", err)) } -- cgit v1.2.3