Firefox-ios: FXIOS-956 ⁃ URLs containing more than one `#` are not detected as URLs

Created on 23 Sep 2020  ·  7Comments  ·  Source: mozilla-mobile/firefox-ios

URLs that contain more than one # are not detected as URLs and when entered in the URL bar open are search request instead.

Steps to reproduce

  1. Open a new tab and tap the URL bar
  2. Type http://example.com/## and press enter
  3. A search on your default search engine will be performed for http://example.com/##

Expected behavior

The webpage http://example.com/## should open.

Actual behavior

A search is performed by the user's default search engine with the search term http://example.com/##.

Device & build information

  • Device: iPhone SE (2016)
  • Build version: 28.2 (2470)

Notes

The reason this is important is that some services use multiple # in their URL. Most prominent candidate is Matrix which uses # for room names. So entering:

https://chat.mozilla.org/#/room/#general:mozilla.org

will also result in a search instead of opening the page.

┆Issue is synchronized with this Jira Task

1 Bug 🐞 P2 QA Verified

All 7 comments

➤ Ashley Thomas commented:

Let's timebox this to 2 to start

@dnarcese
I have raise PR for this please take a look
https://github.com/mozilla-mobile/firefox-ios/pull/7491

Verified fixed on 29.0 (2848).

I disagree. It's only partially fixed on 29.0 (2860).

Opening https://chat.mozilla.org/#/room/#general:mozilla.org by tapping the link works. However copying https://chat.mozilla.org/#/room/#general:mozilla.org, pasting it into the address bar and pressing enter initiates a websearch instead of opening the link. Same with http://example.com/##

When escaping one # with %23, e.g. https://chat.mozilla.org/#/room/%23general:mozilla.org the link opens as it should.

I'm not sure how much Matrix is at fault due to disobeying webspec by using multiple # in their URLs and how much Firefox iOS should do to support this.

@GeckoEidechse the reason it does not work is because url.replacingOccurrences(of: "#", with: "%23", range: start..

this would fix it
var ranges: [Range] = []
while start <= url.endIndex,
let range = url.range(of: "#", range: start..

        ranges.append(range)
        start = range.upperBound
    }

    for range in ranges {

        url.replaceSubrange(range, with:  "%23")
    }

Reverting the last commit (16eaf82610cf4d2d4108bff6297aff453a3c670a) would fix it.
@dnarcese, @SimonBasca
Thanks

hm I just tested with the latest commit and copying and pasting those urls work fine for me.

Oh, it's because this fix hasn't yet landed in release!

Was this page helpful?
0 / 5 - 0 ratings