Skip to content

Commit

Permalink
fix(ipc): ensure lower cased bundle ID in hostname check
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Nov 7, 2024
1 parent 194a5fd commit a1b6ecd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/ipc/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export * from '{{url}}'
String contentLocation;

// application resource or service worker request at `socket://<bundle_identifier>/*`
if (request->hostname == bundleIdentifier) {
if (toLowerCase(request->hostname) == toLowerCase(bundleIdentifier)) {
const auto resolved = this->navigator.location.resolve(request->pathname, applicationResources);

if (resolved.redirect) {
Expand Down Expand Up @@ -715,7 +715,7 @@ export * from '{{url}}'
#else
"socket://" +
#endif
bundleIdentifier +
toLowerCase(bundleIdentifier) +
contentLocation +
(request->query.size() > 0 ? "?" + request->query : "")
);
Expand All @@ -730,7 +730,7 @@ export * from '{{url}}'
{"protocol", "socket"},
{"pathname", pathname},
{"specifier", specifier},
{"bundle_identifier", bundleIdentifier}
{"bundle_identifier", toLowerCase(bundleIdentifier)}
}
);

Expand Down Expand Up @@ -838,7 +838,7 @@ export * from '{{url}}'
#else
"socket://" +
#endif
bundleIdentifier +
toLowerCase(bundleIdentifier) +
"/socket" +
pathname
);
Expand Down Expand Up @@ -1063,9 +1063,9 @@ export * from '{{url}}'
);

registration->SetAllowedOrigins(allowedOriginsCount, allowedOrigins);
if (entry.first != "npm") {
if (entry.first != "npm") {
registration->put_HasAuthorityComponent(true);
}
}
registration->put_TreatAsSecure(true);
registrations[registrationsCount++] = registration.Get();
registrationsSet.insert(registration);
Expand Down
3 changes: 2 additions & 1 deletion src/ipc/scheme_handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ namespace SSC::IPC {
this->absoluteURL = convertWStringToString(requestURI);
if (
this->absoluteURL.starts_with("socket://") &&
!this->absoluteURL.starts_with("socket://" + bundleIdentifier)
!this->absoluteURL.starts_with("socket://" + bundleIdentifier) &&
!this->absoluteURL.starts_with("socket://" + toLowerCase(bundleIdentifier))
) {
this->absoluteURL = String("socket://") + this->absoluteURL.substr(8);
if (this->absoluteURL.ends_with("/")) {
Expand Down

0 comments on commit a1b6ecd

Please sign in to comment.