mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-02 08:15:55 +00:00
fix: write the SIO-Label header without a doubled space after the colon
This commit is contained in:
@@ -58,7 +58,8 @@ describe('SIO-Label', () => {
|
||||
|
||||
it('writes Sensitivity and the extra header only when the label sets them', () => {
|
||||
expect(labelHeaderProperties(confidential, 'X-Classification')).toEqual({
|
||||
'header:SIO-Label:asRaw': sioLabelValue(confidential),
|
||||
// Without the leading space: the server writes "SIO-Label: " itself.
|
||||
'header:SIO-Label:asRaw': 'marking="CONFIDENTIAL"; fgcolor=#000000; bgcolor=#d97706',
|
||||
'header:Sensitivity:asText': 'Company-Confidential',
|
||||
'header:X-Classification:asText': 'Confidential',
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ function percentEncode(value: string): string {
|
||||
/** The marking parameter(s): quoted when ASCII, RFC 2231 (with continuations when long) otherwise. */
|
||||
function markingParameters(marking: string): string[] {
|
||||
const clean = marking.replace(/["\\\r\n]/g, '');
|
||||
// eslint-disable-next-line no-control-regex
|
||||
|
||||
if (/^[\x20-\x7e]*$/.test(clean)) return [`marking="${clean}"`];
|
||||
const encoded = percentEncode(clean);
|
||||
const MAX = 60;
|
||||
@@ -116,13 +116,14 @@ function labelHeaderPairs(label: ClassificationLabel, extraHeader: string): Arra
|
||||
export function labelHeaderProperties(label: ClassificationLabel, extraHeader: string): Record<string, string> {
|
||||
const out: Record<string, string> = {};
|
||||
for (const [name, value, form] of labelHeaderPairs(label, extraHeader)) {
|
||||
out[form === 'raw' ? `header:${name}:asRaw` : `header:${name}:asText`] = value;
|
||||
// The server writes "Name: " itself; a raw value keeps only its own folds.
|
||||
out[form === 'raw' ? `header:${name}:asRaw` : `header:${name}:asText`] = form === 'raw' ? value.trimStart() : value;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function encodedWord(value: string): string {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
|
||||
if (/^[\x20-\x7e]*$/.test(value)) return value;
|
||||
let binary = '';
|
||||
for (const byte of new TextEncoder().encode(value)) binary += String.fromCharCode(byte);
|
||||
|
||||
Reference in New Issue
Block a user