Skip to content

Use MIXED_CONTENT_COMPATIBILITY_MODE in WebView setup#450

Open
jim-daf wants to merge 1 commit into
forkgram:devfrom
jim-daf:fix-webview-mixed-content
Open

Use MIXED_CONTENT_COMPATIBILITY_MODE in WebView setup#450
jim-daf wants to merge 1 commit into
forkgram:devfrom
jim-daf:fix-webview-mixed-content

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 13, 2026

Closes #449.

Six WebView setups in TMessagesProj call setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW):

  • ArticleViewer.java (Instant View renderer)
  • PaymentFormActivity.java (2 occurrences: payment form + 3DS step)
  • WebviewActivity.java (in-app link WebView)
  • Components/EmbedBottomSheet.java (iframe embeds)
  • Components/PhotoViewerWebView.java (YouTube and similar embeds)

MIXED_CONTENT_ALWAYS_ALLOW lets an https page in the WebView load every kind of http sub-resource, including remote scripts. The WebSettings javadoc treats it as the strictly less safe choice.

PaymentFormActivity is the most exposed of the six. Its WebView renders the payment provider HTML and the 3DS challenge, both of which should refuse http sub-resources over an https origin on principle.

Change

Replace MIXED_CONTENT_ALWAYS_ALLOW with MIXED_CONTENT_COMPATIBILITY_MODE on all six call sites. COMPATIBILITY_MODE keeps passive sub-resources (images, fonts) loading on https pages while blocking active mixed content like remote scripts. This matches how Chrome treats mixed content in the address bar.

The change is a single-token swap per call site and does not touch any other WebView setting. Embedded media that legitimately references http images on https pages continues to render.

Six WebView setups in TMessagesProj called

    setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW)

across:

  - ArticleViewer (Instant View renderer)
  - PaymentFormActivity (2 occurrences -- payment form + 3DS step)
  - WebviewActivity (link preview WebView)
  - Components/EmbedBottomSheet (iframe embeds)
  - Components/PhotoViewerWebView (YouTube and similar embeds)

ALWAYS_ALLOW lets an https page in the WebView load every kind of
http sub-resource, including remote scripts. The WebSettings
javadoc treats it as the strictly less-safe choice. For
PaymentFormActivity the WebView renders payment-provider HTML and
the 3DS challenge, both of which should refuse http sub-resources
over an https origin on principle.

Replace with COMPATIBILITY_MODE, which keeps passive sub-resources
(images, fonts) loading on https pages while blocking active mixed
content like remote scripts. This is how Chrome treats mixed content
in the address bar and is the right default for the four embed and
preview surfaces. The change is a single-token swap per call site
and does not touch any other WebView setting.
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.

Six WebView setups call setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW), including the payment form

1 participant