Dependency Graph

Dependency Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0006168SOGowith SOGopublic2026-09-16 08:17
Reportercdmon Assigned Toqhivert  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionreopened 
Platform[Server] LinuxOSUbuntuOS Version16.04 LTS
Product Version5.12.4 
Fixed in Version5.12.5 
Summary0006168: Signature duplication when switching identities while composing email
Description

We have identified an issue with signature management when composing emails with accounts that have multiple identities configured.

Symptoms:

  • When composing a new email, the default user signature is inserted automatically
  • When switching to a different identity, the new identity's signature is added to the message
  • The original default signature is NOT removed, resulting in duplicate signatures
  • Both the default user signature and the identity-specific signature appear in the email body

Expected behavior:
When switching to a different identity while composing an email, the previous signature should be removed and replaced with the signature associated with the newly selected identity. Only one signature should be present at any time.

Steps To Reproduce
  • Configure an email account with multiple identities, each with its own signature
  • Start composing a new email (default signature is inserted)
  • Switch to a different identity using the identity selector
  • Observe that both signatures are now present in the email body
Tagsidentities, identity, signature, sogo

Relationships

related to 0006214 new Signature duplicated when switching identity in compose (regression from 0005695 fix) 

Activities

cdmon

cdmon

2025-12-30 09:59

reporter  

Selección_2374.png (18,765 bytes)   
Selección_2374.png (18,765 bytes)   
qhivert

qhivert

2026-02-05 07:50

administrator   ~0018413

Hello,
I've made a potential fix -> https://github.com/Alinto/sogo/commit/71d865b86a7c11dc6aa8612999ae515f14a3bdf2
Available with next nightly tomorrow.

cdmon

cdmon

2026-03-17 07:56

reporter   ~0018430

Hello,

We updated to 5.12.5 and it still happening.

cdmon

cdmon

2026-03-17 07:57

reporter   ~0018431

We selected diferent identities and it duplicate the signatures.

Selección_2810.png (54,124 bytes)   
Selección_2810.png (54,124 bytes)   
cdmon

cdmon

2026-05-07 12:51

reporter   ~0018451

It is working now with the new version

rof

rof

2026-07-20 08:40

reporter   ~0018524

Hello!

I have a ticket 006214 and I have some notes on there that I would like for you to check. The new version is not working for me because the signatures we are using are too long for the regex. We are currently at ver 5.12.9

Thank you in advance for your time!

cdmon

cdmon

2026-09-15 06:18

reporter   ~0018551

I reopened it, because it still happen:

Environment

  • SOGo: 5.12.10 (Docker)
  • Client: Mailer web UI (MessageEditorController.js), Google Chrome
  • Affected mailbox with 6 configured identities

Problem
When composing a new email and switching the "From" identity, the previous identity's signature is not removed. The new identity's signature is appended below the old one, resulting in duplicated signatures. The duplicate is persisted because drafts are autosaved after the replacement, so the two signatures get consolidated in the draft. Sending then delivers the mail with both signatures.

Reproduction

  1. Open compose view with identity A (default). Its signature is inserted normally.
  2. Switch to identity B from the From selector.
  3. The signature of A stays in the body and B's signature gets appended below it.

Observations

  • Reproducible with 6 identities, each carrying a large (0000063:0000085 KB) HTML signature containing an embedded Base64 image.
  • Also reproduced with a smaller signature using an external image URL (not Base64), replacing the original one — same duplicate behavior.
  • Not reproduced with regular small plain/HTML signatures.
  • No server-side errors; the server logs show normal compose / newDraft.../edit requests.
    Root cause analysis (MessageEditorController.js, setFromIdentity)
    In setFromIdentity the previous signature is located with a RegExp built from the raw signature HTML:
    var currentSignature = new RegExp('(<p>)?...' + currentIdentity.signature)
    if (vm.message.editable.text.search(currentSignature) >= 0) {
    vm.message.editable.text = vm.message.editable.text.replace(currentSignature, signature);
    The HTML is concatenated into the pattern without escaping regex metacharacters. The commented-out line above it shows the original implementation escaped them (e.g. [...].replace(/[-]{}()*+?.,\^$|#\s]/g, '\$&')), which appears to have been lost when 0005695 was merged. HTML signatures commonly contain unescaped characters such as (, ), +, ?, ., {}, | — e.g. rgb(0, 0, 204), font-size:13.3333px, https://... — so the search fails to match (or throws a SyntaxError on unbalanced parentheses) and the old signature is never removed.
    Additionally, the error path for "regex too long" does an append instead of a replace:
    } catch (error) {
    // An error can occur (regex too long) when the signature is too big (using images)
    vm.message.editable.text += signature; // append, no replacement
    return true;
    }
    Both paths converge on the same outcome: _.find reports the signature "was handled" (or not found), so the fallback block appends the new signature, duplicating the old one.

Suggested fix

  • Escape the signature HTML when building the RegExp (restore the escaping from the commented-out implementation), and
  • In the catch path, remove the previous signature (matched by a bounded/loose pattern or a length-limited heuristic) before appending, instead of a plain +=.
    Happy to provide a test case (sample identity JSON with signatures that trigger the failure) or verify a patch.

Issue History

Date Modified Username Field Change
2025-12-30 09:59 cdmon New Issue
2025-12-30 09:59 cdmon Tag Attached: identities
2025-12-30 09:59 cdmon Tag Attached: identity
2025-12-30 09:59 cdmon Tag Attached: signature
2025-12-30 09:59 cdmon Tag Attached: sogo
2025-12-30 09:59 cdmon File Added: Selección_2374.png
2026-02-05 07:50 qhivert Note Added: 0018413
2026-02-05 07:50 qhivert Assigned To => qhivert
2026-02-05 07:50 qhivert Status new => feedback
2026-03-04 09:28 qhivert Status feedback => resolved
2026-03-04 09:28 qhivert Resolution open => fixed
2026-03-04 09:28 qhivert Fixed in Version => 5.12.5
2026-03-17 07:56 cdmon Status resolved => feedback
2026-03-17 07:56 cdmon Resolution fixed => reopened
2026-03-17 07:56 cdmon Note Added: 0018430
2026-03-17 07:57 cdmon Note Added: 0018431
2026-03-17 07:57 cdmon File Added: Selección_2810.png
2026-03-17 07:57 cdmon Status feedback => assigned
2026-05-07 12:51 cdmon Note Added: 0018451
2026-07-20 08:40 rof Note Added: 0018524
2026-09-15 06:18 cdmon Note Added: 0018551
2026-09-16 08:17 Christian Mack Relationship added related to 0006214