From ccf7553c4fbb4e39cb9cc3c31a0dd719da1a9dfe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 2 May 2013 16:46:47 -0400 Subject: cannot open file:// url on Android, so don't use the htmlshim there --- Command/WebApp.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Command') diff --git a/Command/WebApp.hs b/Command/WebApp.hs index da97ed288..30bd2ffab 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -66,7 +66,7 @@ start' allowauto listenhost = do \origout origerr url htmlshim -> if isJust listenhost then maybe noop (`hPutStrLn` url) origout - else openBrowser browser htmlshim origout origerr + else openBrowser browser htmlshim url origout origerr ) auto | allowauto = liftIO startNoRepo @@ -141,7 +141,7 @@ firstRun listenhost = do go | otherwise = do browser <- maybe Nothing webBrowser <$> Git.Config.global - openBrowser browser htmlshim Nothing Nothing + openBrowser browser htmlshim url Nothing Nothing go where go = do @@ -152,8 +152,8 @@ firstRun listenhost = do sendurlback v sendurlback v _origout _origerr url _htmlshim = putMVar v url -openBrowser :: Maybe FilePath -> FilePath -> Maybe Handle -> Maybe Handle -> IO () -openBrowser mcmd htmlshim outh errh = do +openBrowser :: Maybe FilePath -> FilePath -> String -> Maybe Handle -> Maybe Handle -> IO () +openBrowser mcmd htmlshim realurl outh errh = do hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url hFlush stdout environ <- cleanEnvironment @@ -166,10 +166,17 @@ openBrowser mcmd htmlshim outh errh = do unless (exitcode == ExitSuccess) $ hPutStrLn (fromMaybe stderr errh) "failed to start web browser" where - url = fileUrl htmlshim p = case mcmd of Just cmd -> proc cmd [htmlshim] - Nothing -> browserProc htmlshim + Nothing -> browserProc htmlshim url +#ifdef __ANDROID__ + {- Android does not support file:// urls, but neither is + - the security of the url in the process table important + - there, so just use the real url. -} + url = realurl +#else + url = fileUrl htmlshim +#endif {- web.browser is a generic git config setting for a web browser program -} webBrowser :: Git.Repo -> Maybe FilePath -- cgit v1.2.3