Skip to content

Incorrectly replaced all "https://" substrings in URL when redirect from the app to Safari. #2042

@IRN-Kawakaze

Description

@IRN-Kawakaze

Checklist

  • I am reporting an issue in existing functionality that does not work as intended
  • I've searched for existing GitHub issues

Description

Recently in the iOS Telegram app, when user taps a URL and redirect to Safari, app will automatically replaces all "https://" substrings in the URL with "x-safari-https://". This behavior will break the URL when it contain multiple "https://" substrings.

Note: This URL is used only to verify the bug and has no actual purpose, so it still works even after being corrupted by the bug. Affected URLs that have a real purpose would be corrupted by this bug and fail to work properly, like various “search by image” websites.
For example,send this URL in the app and click it to open in Safari:
https://1.1.1.1/cdn-cgi/trace?https://example.com/a.jpg.
The actual URL opened is probably:
x-safari-https://1.1.1.1/cdn-cgi/trace?x-safari-https://example.com/a.jpg.
The actual URL visited in Safari is:
https://1.1.1.1/cdn-cgi/trace?x-safari-https://example.com/a.jpg.

I’m not a professional, so this is just for reference: Since this issue appeared around early March, could it be related to the changes made here?
bae4591#diff-1574ace781887a2bbe54244000d055d1bd577a98490998490c8421889f872cd1R106

Expected Behavior

Only replace "https://" substrings when it appears at the start of the URL.

Actual Behavior

All "https://" substrings in the URL were replaced.

Steps to Reproduce

  1. Set Safari as your default browser.
  2. Send https://1.1.1.1/cdn-cgi/trace?https://example.com/a.jpg in app.
  3. Click this link, it will automatically redirect to Safari.
  4. Click on the Safari address bar to view the URL.
  5. You will see that the URL is: https://1.1.1.1/cdn-cgi/trace?x-safari-https://example.com/a.jpg.

Environment

Device: iPhone 13 Pro Max

iOS version: iOS 26.3.1

App version: 12.5.2 (32493)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions