Skip to content

chore: sync upstream PR #8745 - fix(android): read CapacitorCookies/CapacitorHttp isEnabled from injected global - #273

Open
riderx wants to merge 2 commits into
plusfrom
sync/upstream-pr-8745
Open

riderx wants to merge 2 commits into
plusfrom
sync/upstream-pr-8745

Conversation

@riderx

@riderx riderx commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Merge Conflict Review Required

The sync of upstream PR ionic-team#8745 from @basnijholt encountered merge conflicts.

Original PR: ionic-team#8745

What happened

  • Git applied the upstream-preferred merge strategy
  • This PR requires CI and manual review before merging

Synced from upstream by Capacitor+ Bot


Run Proof on this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@riderx

riderx commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 371da52c-70d1-40c6-a033-a744a4eab244
Commits

Reviewing files that changed from the base of the PR and between 4f9459d and ad922c0.

Files selected for processing: 17

  • ARCHITECTURE.md
  • CHANGELOG.md
  • android/CHANGELOG.md
  • android/capacitor/src/main/assets/native-bridge.js
  • android/capacitor/src/main/java/com/getcapacitor/Bridge.java
  • android/capacitor/src/main/java/com/getcapacitor/JSExport.java
  • android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookies.java
  • android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorHttp.java
  • android/capacitor/src/test/java/com/getcapacitor/JSExportTest.java
  • android/capacitor/src/test/java/com/getcapacitor/plugin/CapacitorCookiesTest.java
  • android/capacitor/src/test/java/com/getcapacitor/plugin/CapacitorHttpTest.java
  • cli/CHANGELOG.md
  • core/CHANGELOG.md
  • core/native-bridge.ts
  • core/src/tests/bridge.spec.ts
  • ios/CHANGELOG.md
  • ios/Sources/Capacitor/assets/native-bridge.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T06:04:42.085002Z ad922c0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Beta npm build

Maintainers can publish one Capacitor Plus workspace package from this PR to npm for fast testing.

Comment /publish-beta <package> after the PR checks are green.

Examples:

/publish-beta core
/publish-beta cli
/publish-beta @capacitor-plus/core

If exactly one workspace package changed, /publish-beta without a package will use that package.

Packages:

  • core (@capacitor-plus/core)
  • cli (@capacitor-plus/cli)
  • android (@capacitor-plus/android)
  • ios (@capacitor-plus/ios)

The workflow will:

  • publish a prerelease package on the beta tag
  • update this comment with the install command

Security note: beta publish is only enabled for branches inside this repository.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e464a7d2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +23 to 24
if (isEnabled()) {
this.bridge.getWebView().addJavascriptInterface(this, "CapacitorCookiesAndroidInterface");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the scoped-bridge guard when enabling cookies

For Android apps using Bridge.Builder.setWebMessagePolicy(...) with CapacitorCookies enabled, this replaces the guard that prevented exposing the cookie interface outside the scoped bridge. Unlike the origin and main-frame checks in MessageHandler, this interface has no caller validation, and its annotated setCookie(String, String) method delegates directly to the native cookie manager. Consequently, untrusted frames can modify cookies for domains outside their own origin despite the configured bridge policy. Retain the !bridge.hasScopedWebMessages() condition alongside the enabled check.

Useful? React with 👍 / 👎.

Comment thread CHANGELOG.md
Comment on lines 214 to 215





## [8.6.5](https://github.com/Cap-go/capacitor-plus/compare/8.6.4...8.6.5) (2026-11-11)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore the CI-managed changelogs

This sync removes historical whitespace from the root and four package changelogs even though these changes are unrelated to the bridge fix. The root AGENTS.md explicitly reserves CHANGELOG.md updates for CI/CD and prohibits manual edits. Revert the changelog modifications and leave their regeneration to the release workflow.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 17 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookies.java">

<violation number="1" location="android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookies.java:23">
P1: This drops the `hasScopedWebMessages()` guard, so with scoped web messages and `CapacitorCookies.enabled`, `CapacitorCookiesAndroidInterface` (including `setCookie`) is exposed through `addJavascriptInterface` to any origin the WebView loads. Keep the scoped check and add the enabled check: `if (!bridge.hasScopedWebMessages() && isEnabled())`.</violation>
</file>

<file name="core/src/tests/bridge.spec.ts">

<violation number="1" location="core/src/tests/bridge.spec.ts:132">
P2: This removes the only tests covering binary fetch handling (Blob and ArrayBuffer request bodies, and byte-for-byte binary responses). The native-bridge.ts logic for these paths is unchanged, so the regressions would go undetected. Restore these three tests, or move them to the new config-based setup.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@Override
public void load() {
if (!bridge.hasScopedWebMessages()) {
if (isEnabled()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This drops the hasScopedWebMessages() guard, so with scoped web messages and CapacitorCookies.enabled, CapacitorCookiesAndroidInterface (including setCookie) is exposed through addJavascriptInterface to any origin the WebView loads. Keep the scoped check and add the enabled check: if (!bridge.hasScopedWebMessages() && isEnabled()).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookies.java, line 23:

<comment>This drops the `hasScopedWebMessages()` guard, so with scoped web messages and `CapacitorCookies.enabled`, `CapacitorCookiesAndroidInterface` (including `setCookie`) is exposed through `addJavascriptInterface` to any origin the WebView loads. Keep the scoped check and add the enabled check: `if (!bridge.hasScopedWebMessages() && isEnabled())`.</comment>

<file context>
@@ -20,7 +20,7 @@ public class CapacitorCookies extends Plugin {
     @Override
     public void load() {
-        if (!bridge.hasScopedWebMessages()) {
+        if (isEnabled()) {
             this.bridge.getWebView().addJavascriptInterface(this, "CapacitorCookiesAndroidInterface");
         }
</file context>
Suggested change
if (isEnabled()) {
if (!bridge.hasScopedWebMessages() && isEnabled()) {

});
});

it('android patched fetch sends Blob bodies as base64 binary data', async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This removes the only tests covering binary fetch handling (Blob and ArrayBuffer request bodies, and byte-for-byte binary responses). The native-bridge.ts logic for these paths is unchanged, so the regressions would go undetected. Restore these three tests, or move them to the new config-based setup.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At core/src/tests/bridge.spec.ts, line 132:

<comment>This removes the only tests covering binary fetch handling (Blob and ArrayBuffer request bodies, and byte-for-byte binary responses). The native-bridge.ts logic for these paths is unchanged, so the regressions would go undetected. Restore these three tests, or move them to the new config-based setup.</comment>

<file context>
@@ -129,119 +129,53 @@ describe('bridge', () => {
-    expect(callData.options.data).toBe('AQI=');
-    expect(callData.options.dataType).toBe('binary');
-    expect(callData.options.headers['content-type']).toBe('application/octet-stream');
+  it('android patches fetch when CapacitorNativeConfig.httpEnabled is true without CapacitorHttpAndroidInterface', () => {
+    const originalFetch = window.fetch;
+    const originalXHR = window.XMLHttpRequest;
</file context>

Comment thread ARCHITECTURE.md Resolved
@riderx

riderx commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

@riderx
riderx force-pushed the sync/upstream-pr-8745 branch 2 times, most recently from a45c59a to 8d46964 Compare November 27, 2026 06:03
@riderx

riderx commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

@riderx
riderx force-pushed the sync/upstream-pr-8745 branch from 8d46964 to ad922c0 Compare November 28, 2026 06:03
@riderx

riderx commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants