Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In case of exception we return an html page in case the client is a b… #23557

Merged
merged 2 commits into from
Apr 4, 2016

Conversation

DeepDiver1975
Copy link
Member

…rowser

@PVince81 @LukasReschke the plugin approach to fix #23500

@DeepDiver1975 DeepDiver1975 added this to the 9.1-current milestone Mar 24, 2016
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @LukasReschke, @icewind1991, @PVince81 and @DeepDiver1975 to be potential reviewers

if ($request->getMethod() !== 'GET') {
return false;
}
return $request->isUserAgent([Request::USER_AGENT_IE_8]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasReschke this is where I need all the mighty regex 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:godmode:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 9.0 we don't support IE8 any more 🔥
Only IE >= 9
See #15567 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81
Copy link
Contributor

Wow, nicely done!

@PVince81
Copy link
Contributor

  % curl -D - -X GET http://admin:admin@localhost/owncloud/remote.php/webdav/unexist.txt
HTTP/1.1 404 Not Found
Date: Thu, 24 Mar 2016 13:53:17 GMT
Server: Apache/2.4.18 (Linux/SUSE)
X-Powered-By: PHP/5.6.17
Set-Cookie: ockbfur1449k=f7fmc1arrtqi598dllgfb6l366n7pie51e9pbuil3bakk7jgc2t0; path=/owncloud; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: oc_sessionPassphrase=8llD2Q0WIFsVE%2BR2B4jwmE1lPUe3xjCeIpUaDf09EryVbncZvLtT0iUZogjAOWTr%2BlRfMRLfo2sbYGrU7juCQZcBE%2Fuj%2BErg0nxXTa1Ewq3VgWaAGkC7j98iNOmlHrCf; path=/owncloud; httponly
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: Sameorigin
X-Robots-Tag: none
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Set-Cookie: ockbfur1449k=ho2b75ldlig380825usce0o5o207mrpd6ndja1k6fueln2iqlv40; path=/owncloud; HttpOnly
Content-Length: 239
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
  <s:message>File with name unexist.txt could not be located</s:message>
</d:error>

Browser doesn't display a page:
webdav-error-unexist

@PVince81
Copy link
Contributor

Haha, maybe another trick would be to produce a XSLT file with style information ? 😛

@PVince81
Copy link
Contributor

isBrowserRequest is always false ??

@LukasReschke
Copy link
Member

Browser doesn't display a page:

#23557 (comment)

… I'm still writing that magical Regex 😉 …

@DeepDiver1975
Copy link
Member Author

Browser doesn't display a page:

@LukasReschke has to add his :godmode: regex - sorry - I was adding the 'to review' label too early

@@ -333,7 +333,7 @@ public static function printErrorPage( $error_msg, $hint = '' ) {
* print error page using Exception details
* @param Exception $exception
*/
public static function printExceptionErrorPage($exception) {
public static function printExceptionErrorPage($exception, $fetchPage = false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPDoc 😉

Request::USER_AGENT_MS_EDGE,
Request::USER_AGENT_CHROME,
Request::USER_AGENT_FIREFOX,
Request::USER_AGENT_SAFARI,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too bad we can't just rely on "Accept" headers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Clients are fun 🙈

Once we have tokens this will be easy though since we know where the token belongs to.

@PVince81
Copy link
Contributor

We're almost there. The page says "Internal Server Error".
Can we make it display the actual error ? Like "File not found" for a 404 ?

@DeepDiver1975
Copy link
Member Author

We're almost there. The page says "Internal Server Error".
Can we make it display the actual error ? Like "File not found" for a 404 ?

how are you triggering the error?

@PVince81
Copy link
Contributor

See #23557 (comment)

It has the Webdav download link with a non-existing file.

@PVince81
Copy link
Contributor

Just open "http://localhost/owncloud/remote.php/webdav/unexist.txt" in Chromium 48 (after being logged in)

@DeepDiver1975
Copy link
Member Author

Okay - the real http status code is 404 and the explicit exception message is listed as well.

I simply used out exception error page which always prints 'internal server error'

@PVince81
Copy link
Contributor

It's not listed in my case:
chrome-error

@DeepDiver1975
Copy link
Member Author

It's not listed in my case:

ah - yes - the excption details are only displayed in debug mode.

What was the behavior with the ajax download? Which page did we display there?

@PVince81
Copy link
Contributor

It used to look like this in 8.2 with ajax download:
chrome-old-error

@DeepDiver1975
Copy link
Member Author

I see it explicitly renders the 404 template ....

@DeepDiver1975
Copy link
Member Author

I'm also getting a permanent reload loop here - due to NotAuthenticated

@DeepDiver1975
Copy link
Member Author

Okay - special 404 template added - any other cases we want to handle different?

@PVince81
Copy link
Contributor

403 in case it's blocked by the firewall or the file could not be decrypted, 423 if the file is locked.

Do these have to be handled one by one ?

@PVince81
Copy link
Contributor

Let me have a quick test with encryption

@PVince81
Copy link
Contributor

Tried with encryption and on stable8.2 the download runs forever... no page displayed 😦
On this branch no page, but Chromium shows its own "Invalid request" page.
I guess the "DecryptionFailedException" was never caught properly.

@PVince81
Copy link
Contributor

I thought we could just take whatever status code we have + exception name + exception description (if any) from the XML and display it as is in a page. But not "Internal Server Error".

@PVince81
Copy link
Contributor

Firewall blocking also shows "Internal Server Error" instead of "Forbidden" on this PR.

@DeepDiver1975
Copy link
Member Author

I thought we could just take whatever status code we have + exception name + exception description (if any) from the XML and display it as is in a page. But not "Internal Server Error".

I'll take care of that ....

@DeepDiver1975
Copy link
Member Author

bildschirmfoto von 2016-03-24 17-50-17

@PVince81
Copy link
Contributor

webdav-firewall

Looks great 👍

@DeepDiver1975
Copy link
Member Author

let me squash that stuff a bit and then we can merge

@karlitschek do we want to backport this?

@karlitschek
Copy link
Contributor

agreed. please backport :+1

@DeepDiver1975
Copy link
Member Author

agreed. please backport :+1

THX - here we go #23574

@lock
Copy link

lock bot commented Aug 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error page is missing, just a xml appear.
5 participants