Githawk: Opening a shorthand url crashes the app

Created on 17 Aug 2017  路  9Comments  路  Source: GitHawkApp/GitHawk

Version 1.5.0 (1330)
Device: iPhone 7 Plus (iOS 10.3.3)

Was reading the Rebranding issue and tapped the @GitHawk... and the app crashed.

馃悰 bug

All 9 comments

馃, apparently the user does exist. Does this crash for every mention then?

It doesn't. Let me investigate

This is pretty bad. URLs like "github.com" or "twitter.com" crash the app, as they are not prefixed with http:// or https://

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000109844b0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001092a9141 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001098ad625 +[NSException raise:format:] + 197
    3   SafariServices                      0x000000010a5cff8a -[SFSafariViewController initWithURL:entersReaderIfAvailable:] + 450
    4   Freetime                            0x0000000107b20b47 _TTOFCSo22SFSafariViewControllercfT3urlV10Foundation3URL_S_ + 55
    5   Freetime                            0x0000000107b1bb01 _TFCSo22SFSafariViewControllerCfT3urlV10Foundation3URL_S_ + 65
    6   Freetime                            0x0000000107b6418e _TFE8FreetimeCSo16UIViewController13presentSafarifT3urlV10Foundation3URL_T_ + 62
    7   Freetime                            0x0000000107b64462 _TToFE8FreetimeCSo16UIViewController13presentSafarifT3urlV10Foundation3URL_T_ + 66
    8   Freetime                            0x0000000107b6c79c _TFE8FreetimeCSo16UIViewController9didTapURLfT4viewCS_20AttributedStringView3urlV10Foundation3URL_T_ + 76
    9   Freetime                            0x0000000107b6c827 _TToFE8FreetimeCSo16UIViewController9didTapURLfT4viewCS_20AttributedStringView3urlV10Foundation3URL_T_ + 87
    10  Freetime                            0x0000000107a78fb0 _TTDFE8FreetimeCSo16UIViewController9didTapURLfT4viewCS_20AttributedStringView3urlV10Foundation3URL_T_ + 80
    11  Freetime                            0x0000000107a78f49 _TTWCSo16UIViewController8Freetime28AttributedStringViewDelegateS0_FS1_9didTapURLfT4viewCS0_20AttributedStringView3urlV10Foundation3URL_T_ + 57
    12  Freetime                            0x0000000107b16390 _TFC8Freetime20AttributedStringView5onTapfT10recognizerCSo22UITapGestureRecognizer_T_ + 1248
    13  Freetime                            0x0000000107b167fa _TToFC8Freetime20AttributedStringView5onTapfT10recognizerCSo22UITapGestureRecognizer_T_ + 58
    14  UIKit                               0x000000010ac3af59 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
    15  UIKit                               0x000000010ac42d57 _UIGestureRecognizerSendTargetActions + 109
    16  UIKit                               0x000000010ac4070b _UIGestureRecognizerSendActions + 225
    17  UIKit                               0x000000010ac3f9ce -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 981
    18  UIKit                               0x000000010ac2c152 _UIGestureEnvironmentUpdate + 1219
    19  UIKit                               0x000000010ac2bc43 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
    20  UIKit                               0x000000010ac2ae0a -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
    21  UIKit                               0x000000010a776eea -[UIWindow sendEvent:] + 4092
    22  UIKit                               0x000000010a723a84 -[UIApplication sendEvent:] + 352
    23  FLEX                                0x00000001088de0a2 __35+[FLEXKeyboardShortcutManager load]_block_invoke.108 + 1026
    24  UIKit                               0x000000010af075d4 __dispatchPreprocessedEventFromEventQueue + 2926
    25  UIKit                               0x000000010aeff532 __handleEventQueue + 1122
    26  CoreFoundation                      0x00000001097eac01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    27  CoreFoundation                      0x00000001097d00cf __CFRunLoopDoSources0 + 527
    28  CoreFoundation                      0x00000001097cf5ff __CFRunLoopRun + 911
    29  CoreFoundation                      0x00000001097cf016 CFRunLoopRunSpecific + 406
    30  GraphicsServices                    0x000000011188ea24 GSEventRunModal + 62
    31  UIKit                               0x000000010a706134 UIApplicationMain + 159
    32  Freetime                            0x0000000107acaad7 main + 55
    33  libdyld.dylib                       0x000000010db1765d start + 1
    34  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This would be such an ugly fix, not knowing if you should use http or https. 馃槓

Ha. I just learned as well that links like these are opened like relative paths in your GitHub repo on GitHub itself. (eg. githawk.com). It's a bit of an edge case though, as the URL is forced via Markdown. Otherwise these would just not be picked up as URLs and not be tappable.

@BasThomas Alwayshttps ;)

But that doesn't guarantee that all those links work, as not every website has switched to https.

Will work on a fix for this, easy to repro

@BasThomas I understand that. I just suggested an easy fix where https was considered the safest option. I would assume you could do a HEAD request to the https-first and if this fails fallback to http. That's the common way to check if an url exists. Avoids downloading the content.

The HTTP HEAD method requests the headers that are returned if the specified resource would be requested with an HTTP GET method. Such a request can be done before deciding to download a large resource to save bandwidth, for example. (MDN)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rnystrom picture rnystrom  路  3Comments

BasThomas picture BasThomas  路  3Comments

BasThomas picture BasThomas  路  3Comments

BasThomas picture BasThomas  路  3Comments

BasThomas picture BasThomas  路  3Comments