WebBrowser will be crashed if url include '%' in iOS


WebBrowser will be crashed if url include ‘%’ in iOS.

Exception 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported.' was thrown while invoking openBrowserAsync on target ExponentWebBrowser with params (
callstack: (
	0   CoreFoundation                      0x00000001849f6da4 <redacted> + 252
	1   libobjc.A.dylib                     0x0000000183bb05ec objc_exception_throw + 56
	2   CoreFoundation                      0x00000001849f6c6c <redacted> + 0
	3   SafariServices                      0x0000000199e335e8 <redacted> + 96
	4   Exponent                            0x00000001057283b4 ABI27_0_0RCTFBQuickPerformanceLoggerConfigureHooks + 1560572
	5   CoreFoundation                      0x00000001849fe580 <redacted> + 144
	6   CoreFoundation                      0x00000001848dd748 <redacted> + 284
	7   CoreFoundation                      0x00000001848e256c <redacted> + 60
	8   Exponent                            0x000000010579f7d4 ABI28_0_0RCTFBQuickPerformanceLoggerConfigureHooks + 350784
	9   Exponent                            0x00000001057a69d8 ABI28_0_0RCTFBQuickPerformanceLoggerConfigureHooks + 379972
	10  Exponent                            0x00000001057a6738 ABI28_0_0RCTFBQuickPerformanceLoggerConfigureHooks + 379300
	11  libdispatch.dylib                   0x00000001842e8aa0 <redacted> + 24
	12  libdispatch.dylib                   0x00000001842e8a60 <redacted> + 16
	13  libdispatch.dylib                   0x0000000184329d80 <redacted> + 964
	14  CoreFoundation                      0x000000018499f070 <redacted> + 12
	15  CoreFoundation                      0x000000018499cbc8 <redacted> + 2272
	16  CoreFoundation                      0x00000001848bcda8 CFRunLoopRunSpecific + 552
	17  GraphicsServices                    0x00000001868a2020 GSEventRunModal + 100
	18  UIKit                               0x000000018e8dc758 UIApplicationMain + 236
	19  Exponent                            0x0000000104c23a24 Exponent + 932388
	20  libdyld.dylib                       0x000000018434dfc0 <redacted> + 4



I think that this is an invalid URI. I can’t find any examples of %u at RFC-3986. I only see "%" HEXDIG HEXDIG and u is not a HEXDIG because it is not one of 0123456789abcdef.

The way your URI is encoded reminds me of how one would encode a string in C or JavaScript or Python. For example, you can use this escaping in node:

> console.log('\u4E91\u5357')

Instead, you should try using proper URI encoding:

const valueToSearch = '云南';
const correctUri = `http://shoudian.bjx.com.cn/zt.asp?topic=${encodeURIComponent(valueToSearch)}`;

The value of correctUri will be this: http://shoudian.bjx.com.cn/zt.asp?topic=%E4%BA%91%E5%8D%97. There is a better chance that trying to send that to a web browser on your platform will succeed.

Please let me know if that helped!

1 Like

I already tried that,but url return 404. topic must be %u4E91%u5357


That’s interesting. I can see that Firefox allows such invalid URIs. I’m surprised that notation even exists. According to Wikipedia, this is nonstandard and has been rejected by W3C.

On Mobile Safari, that link works if you type it in manually. However, if you visit that page in Mobile Safari and press the “share → Copy” button, it creates a 404 link: http://shoudian.bjx.com.cn/zt.asp?topic=%25u4E91%25u5357. If I try to launch Mobile Safari using its built-in QR code reader (from the camera app), it also uses that same URI. This suggests to me that this is an iOS limitation. The fact that it is nonstandard lowers the chance that iOS add support for it. I’m not certain if this is actually an iOS limitation or Expo API limitation, but I would not be surprised if it were an iOS limitation.

It seems like the website is using and, oddly, requiring clients to use non-standard URIs. I recommend creating your own redirector website and launching the browser to point at that as a work around. I tried doing the redirect locally with data: and javascript: links and those didn’t work on iOS for me, so seems like the redirector has to be a real site.

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.