Skip to content

Commit

Permalink
fix: pr reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanmo226 committed Dec 23, 2024
1 parent b0681ba commit 7b5e25f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extension/chrome/elements/pgp_block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class PgpBlockView extends View {
this.quoteModule.separateQuotedContentAndRenderText(
data.separateQuotedContentAndRenderText.decryptedContent,
data.separateQuotedContentAndRenderText.isHtml,
data.separateQuotedContentAndRenderText.isCheckSumInvalid
data.separateQuotedContentAndRenderText.isChecksumInvalid
);
}
if (data?.setFrameColor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Xss } from '../../../js/common/platform/xss.js';
export class PgpBlockViewQuoteModule {
public constructor(private view: PgpBlockView) {}

public separateQuotedContentAndRenderText = (decryptedContent: string, isHtml: boolean, isCheckSumInvalid: boolean) => {
public separateQuotedContentAndRenderText = (decryptedContent: string, isHtml: boolean, isChecksumInvalid: boolean) => {
if (isHtml) {
const message = $('<div>').html(Xss.htmlSanitizeKeepBasicTags(decryptedContent)); // xss-sanitized
let htmlBlockQuoteExists = false;
Expand All @@ -32,10 +32,10 @@ export class PgpBlockViewQuoteModule {
message[0].removeChild(shouldBeQuoted[i]);
quotedHtml += shouldBeQuoted[i].outerHTML;
}
this.view.renderModule.renderContent(message.html(), false, isCheckSumInvalid);
this.view.renderModule.renderContent(message.html(), false, isChecksumInvalid);
this.appendCollapsedQuotedContentButton(quotedHtml, true);
} else {
this.view.renderModule.renderContent(decryptedContent, false, isCheckSumInvalid);
this.view.renderModule.renderContent(decryptedContent, false, isChecksumInvalid);
}
} else {
const lines = decryptedContent.split(/\r?\n/);
Expand All @@ -62,7 +62,7 @@ export class PgpBlockViewQuoteModule {
// only got quoted part, no real text -> show everything as real text, without quoting
lines.push(...linesQuotedPart.splice(0, linesQuotedPart.length));
}
this.view.renderModule.renderContent(Str.escapeTextAsRenderableHtml(lines.join('\n')), false, isCheckSumInvalid);
this.view.renderModule.renderContent(Str.escapeTextAsRenderableHtml(lines.join('\n')), false, isChecksumInvalid);
if (linesQuotedPart.join('').trim()) {
this.appendCollapsedQuotedContentButton(linesQuotedPart.join('\n'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ export class PgpBlockViewRenderModule {
});
};

public renderContent = (htmlContent: string, isErr: boolean, isCheckSumInvalid = false) => {
public renderContent = (htmlContent: string, isErr: boolean, isChecksumInvalid = false) => {
let contentWithLink = linkifyHtml(htmlContent);

if (isChecksumInvalid) {
contentWithLink = `<div class="pgp-invalid-checksum">${Lang.pgpBlock.invalidCheckSum}</div>${contentWithLink}}`;
}
// Temporary workaround for an issue where 'cryptup_reply' divs are not being hidden when replying to all
// messages from the FES. The root cause is that FES currently returns the body of
// password message replies as 'text/plain', which does not hide the divs as intended.
// This workaround can be safely removed once the FES is updated to return the body of message replies as 'text/html'.
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5004
if (isCheckSumInvalid) {
contentWithLink = `<div class="pgp-invalid-checksum">${Lang.pgpBlock.invalidCheckSum}</div>${contentWithLink}}`;
}
const regEx = /&lt;div[^&]*class="[^"]*cryptup_reply[^"]*"[^&]*&gt;&lt;\/div&gt;/g;
contentWithLink = contentWithLink.replace(regEx, match => {
return match.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
Expand Down
4 changes: 2 additions & 2 deletions extension/js/common/message-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export class MessageRenderer {
renderModule: RenderInterface,
retryVerification: (() => Promise<VerifyRes | undefined>) | undefined,
plainSubject: string | undefined,
isCheckSumInvalid = false
isChecksumInvalid = false
): Promise<{ publicKeys?: string[] }> => {
if (isEncrypted) {
renderModule.renderEncryptionStatus('encrypted');
Expand Down Expand Up @@ -604,7 +604,7 @@ export class MessageRenderer {
);
}
decryptedContent = this.clipMessageIfLimitExceeds(decryptedContent);
renderModule.separateQuotedContentAndRenderText(decryptedContent, isHtml, isCheckSumInvalid);
renderModule.separateQuotedContentAndRenderText(decryptedContent, isHtml, isChecksumInvalid);
await MessageRenderer.renderPgpSignatureCheckResult(renderModule, sigResult, Boolean(signerEmail), retryVerification);
if (renderableAttachments.length) {
renderModule.renderInnerAttachments(renderableAttachments, isEncrypted);
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/render-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface RenderInterface extends RenderInterfaceBase {
renderPassphraseNeeded(longids: string[]): void;
renderErr(errBoxContent: string, renderRawMsg: string | undefined, errMsg?: string): void;
renderInnerAttachments(attachments: TransferableAttachment[], isEncrypted: boolean): void;
separateQuotedContentAndRenderText(decryptedContent: string, isHtml: boolean, isCheckSumInvalid: boolean): void;
separateQuotedContentAndRenderText(decryptedContent: string, isHtml: boolean, isChecksumInvalid: boolean): void;
renderVerificationInProgress(): void;
renderSignatureOffline(retry: () => void): void;
}
2 changes: 1 addition & 1 deletion extension/js/common/render-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type MessageInfo = {
export type RenderMessage = {
done?: true;
resizePgpBlockFrame?: true;
separateQuotedContentAndRenderText?: { decryptedContent: string; isHtml: boolean; isCheckSumInvalid: boolean };
separateQuotedContentAndRenderText?: { decryptedContent: string; isHtml: boolean; isChecksumInvalid: boolean };
renderText?: string;
progressOperation?: { operationId: string; text: string; perc?: number; init?: boolean };
setFrameColor?: 'green' | 'gray' | 'red';
Expand Down
4 changes: 2 additions & 2 deletions extension/js/common/render-relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class RenderRelay implements RenderInterface {
this.relay({ resizePgpBlockFrame: true });
};

public separateQuotedContentAndRenderText = (decryptedContent: string, isHtml: boolean, isCheckSumInvalid: boolean) => {
this.relay({ separateQuotedContentAndRenderText: { decryptedContent, isHtml, isCheckSumInvalid } });
public separateQuotedContentAndRenderText = (decryptedContent: string, isHtml: boolean, isChecksumInvalid: boolean) => {
this.relay({ separateQuotedContentAndRenderText: { decryptedContent, isHtml, isChecksumInvalid } });
};

public renderText = (text: string) => {
Expand Down

0 comments on commit 7b5e25f

Please sign in to comment.