mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
[PM-28038][PM-28276] Ignore url case for origin matching (#17355)
* ignore url case for origin matching * Fixup typo * Inject log services
This commit is contained in:
@@ -548,7 +548,7 @@ export default class MainBackground {
|
|||||||
this.memoryStorageForStateProviders = new BrowserMemoryStorageService(); // mv3 stores to storage.session
|
this.memoryStorageForStateProviders = new BrowserMemoryStorageService(); // mv3 stores to storage.session
|
||||||
this.memoryStorageService = this.memoryStorageForStateProviders;
|
this.memoryStorageService = this.memoryStorageForStateProviders;
|
||||||
} else {
|
} else {
|
||||||
this.memoryStorageForStateProviders = new BackgroundMemoryStorageService(); // mv2 stores to memory
|
this.memoryStorageForStateProviders = new BackgroundMemoryStorageService(this.logService); // mv2 stores to memory
|
||||||
this.memoryStorageService = this.memoryStorageForStateProviders;
|
this.memoryStorageService = this.memoryStorageForStateProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ export class BrowserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize both URLs by removing trailing slashes
|
// Normalize both URLs by removing trailing slashes
|
||||||
const normalizedOrigin = sender.origin.replace(/\/$/, "");
|
const normalizedOrigin = sender.origin.replace(/\/$/, "").toLowerCase();
|
||||||
const normalizedExtensionUrl = extensionUrl.replace(/\/$/, "");
|
const normalizedExtensionUrl = extensionUrl.replace(/\/$/, "").toLowerCase();
|
||||||
|
|
||||||
if (!normalizedOrigin.startsWith(normalizedExtensionUrl)) {
|
if (!normalizedOrigin.startsWith(normalizedExtensionUrl)) {
|
||||||
logger?.warning(
|
logger?.warning(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
|
|
||||||
|
import { LogService } from "@bitwarden/logging";
|
||||||
import { SerializedMemoryStorageService } from "@bitwarden/storage-core";
|
import { SerializedMemoryStorageService } from "@bitwarden/storage-core";
|
||||||
|
|
||||||
import { BrowserApi } from "../browser/browser-api";
|
import { BrowserApi } from "../browser/browser-api";
|
||||||
@@ -11,14 +12,14 @@ import { portName } from "./port-name";
|
|||||||
export class BackgroundMemoryStorageService extends SerializedMemoryStorageService {
|
export class BackgroundMemoryStorageService extends SerializedMemoryStorageService {
|
||||||
private _ports: chrome.runtime.Port[] = [];
|
private _ports: chrome.runtime.Port[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor(private readonly logService: LogService) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
BrowserApi.addListener(chrome.runtime.onConnect, (port) => {
|
BrowserApi.addListener(chrome.runtime.onConnect, (port) => {
|
||||||
if (port.name !== portName(chrome.storage.session)) {
|
if (port.name !== portName(chrome.storage.session)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BrowserApi.senderIsInternal(port.sender)) {
|
if (!BrowserApi.senderIsInternal(port.sender, this.logService)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { trackEmissions } from "@bitwarden/common/../spec/utils";
|
import { trackEmissions } from "@bitwarden/common/../spec/utils";
|
||||||
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
|
||||||
|
import { LogService } from "@bitwarden/logging";
|
||||||
|
|
||||||
import { mockPorts } from "../../../spec/mock-port.spec-util";
|
import { mockPorts } from "../../../spec/mock-port.spec-util";
|
||||||
|
|
||||||
@@ -14,11 +17,13 @@ import { ForegroundMemoryStorageService } from "./foreground-memory-storage.serv
|
|||||||
describe.skip("foreground background memory storage interaction", () => {
|
describe.skip("foreground background memory storage interaction", () => {
|
||||||
let foreground: ForegroundMemoryStorageService;
|
let foreground: ForegroundMemoryStorageService;
|
||||||
let background: BackgroundMemoryStorageService;
|
let background: BackgroundMemoryStorageService;
|
||||||
|
let logService: MockProxy<LogService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockPorts();
|
mockPorts();
|
||||||
|
logService = mock();
|
||||||
|
|
||||||
background = new BackgroundMemoryStorageService();
|
background = new BackgroundMemoryStorageService(logService);
|
||||||
foreground = new ForegroundMemoryStorageService();
|
foreground = new ForegroundMemoryStorageService();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user