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

pdf viewer does not open in a public link share #286

Closed
livier opened this issue Jan 15, 2021 · 27 comments
Closed

pdf viewer does not open in a public link share #286

livier opened this issue Jan 15, 2021 · 27 comments

Comments

@livier
Copy link

livier commented Jan 15, 2021

Steps to reproduce

  1. Share a pdf file with public link
  2. Test the link

Expected behaviour

Pdf viewer should open

Actual behaviour

Only see the download page

Server configuration detail

Operating system: Linux 5.4.41-1-pve #1 SMP PVE 5.4.41-1 (Fri, 15 May 2020 15:06:08 +0200) x86_64

Webserver: Apache/2.4.25 (Debian) (apache2handler)

Database: mysql 10.1.47

PHP version:

7.3.25-1+020201130.73+debian91.gbp042074
Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, apache2handler, mysqlnd, PDO, xml, apcu, bcmath, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, intl, json, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, Zend OPcache

Nextcloud version: 20.0.5 - 20.0.5.2

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: unknown

Signing status

Array
(
)

List of activated apps
Enabled:
 - accessibility: 1.6.0
 - activity: 2.13.4
 - analytics: 3.2.0
 - apporder: 0.11.0
 - bruteforcesettings: 2.0.1
 - calendar: 2.1.3
 - cloud_federation_api: 1.3.0
 - comments: 1.10.0
 - contacts: 3.4.3
 - contactsinteraction: 1.1.0
 - dashboard: 7.0.0
 - dav: 1.16.2
 - deck: 1.2.3
 - duplicatefinder: 0.0.4
 - encryption: 2.8.1
 - federatedfilesharing: 1.10.2
 - federation: 1.10.1
 - files: 1.15.0
 - files_downloadactivity: 1.9.0
 - files_pdfviewer: 2.0.1
 - files_sharing: 1.12.2
 - files_trashbin: 1.10.1
 - files_versions: 1.13.0
 - files_videoplayer: 1.9.0
 - impersonate: 1.7.0
 - issuetemplate: 0.7.0
 - logreader: 2.5.0
 - lookup_server_connector: 1.8.0
 - mail: 1.7.2
 - maps: 0.1.8
 - nextcloud_announcements: 1.9.0
 - notifications: 2.8.0
 - oauth2: 1.8.0
 - password_policy: 1.10.1
 - photos: 1.2.3
 - polls: 1.6.3
 - privacy: 1.4.0
 - provisioning_api: 1.10.0
 - quickaccesssorting: 1.1.2
 - richdocuments: 3.7.11
 - serverinfo: 1.10.0
 - settings: 1.2.0
 - sharebymail: 1.10.0
 - spreed: 10.0.5
 - survey_client: 1.8.0
 - systemtags: 1.10.0
 - tasks: 0.13.6
 - text: 3.1.0
 - theming: 1.11.0
 - theming_customcss: 1.8.0
 - twofactor_backupcodes: 1.9.0
 - twofactor_totp: 5.0.0
 - unsplash: 1.1.7
 - updatenotification: 1.10.0
 - user_status: 1.0.1
 - viewer: 1.4.0
 - weather_status: 1.0.0
 - workflowengine: 2.2.0
Disabled:
 - admin_audit
 - circles
 - files_accesscontrol
 - files_external
 - files_rightclick
 - firstrunwizard
 - groupfolders
 - phonetrack
 - recommendations
 - support
 - user_ldap

Configuration (config/config.php)
{
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "un.autre.domaine.tld",
        "cloud.penserpouragir.org"
    ],
    "overwrite.cli.url": "https:\/\/cloud.penserpouragir.org",
    "Overwriteprotocol": "https",
    "dbtype": "mysql",
    "version": "20.0.5.2",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "default_language": "fr",
    "installed": true,
    "loglevel": 0,
    "log_type": "file",
    "logfile": "\/var\/log\/nextcloud.log",
    "log_rotate_size": 52428800,
    "maintenance": false,
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpmode": "smtp",
    "mail_smtpauthtype": "LOGIN",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpsecure": "tls",
    "mail_smtpauth": 1,
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "587",
    "theme": "",
    "updater.release.channel": "stable",
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "skeletondirectory": "\/var\/nextcloud-data\/skeleton",
    "mysql.utf8mb4": true,
    "memcache.local": "\\OC\\Memcache\\APCu",
    "encryption.legacy_format_support": false,
    "encryption.key_storage_migrated": false,
    "enable_previews": true,
    "preview_max_x": 4096,
    "preview_max_y": 4096,
    "preview_max_filesize_image": 50,
    "enabledPreviewProviders": [
        "OC\\Preview\\PNG",
        "OC\\Preview\\JPEG",
        "OC\\Preview\\GIF",
        "OC\\Preview\\HEIC",
        "OC\\Preview\\BMP",
        "OC\\Preview\\XBitmap",
        "OC\\Preview\\MP3",
        "OC\\Preview\\TXT",
        "OC\\Preview\\MarkDown",
        "OC\\Preview\\OpenDocument",
        "OC\\Preview\\Krita",
        "OC\\Preview\\PDF"
    ],
    "updater.secret": "***REMOVED SENSITIVE VALUE***"
}

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption:

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

Client configuration

Browser: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0

Operating system:

Logs

Web server error log
Insert your web server log here 
Nextcloud log
Insert your Nextcloud log here
Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log
c) ...
@skjnldsv
Copy link
Member

Can you provide a link for me to test?
Works fine for me 🤔

@szaimen
Copy link
Collaborator

szaimen commented Jan 24, 2021

Maybe it is this problem?
nextcloud/richdocuments#1320

@gsnendzynskigmbh
Copy link

gsnendzynskigmbh commented Feb 3, 2021

I can confirm the issue, it seems to work with a nextcloud 20.0.5 Instance but a 20.0.6 and a 20.0.7 Instance shows me a error if I open

Not Working Link:
Shared folder contains a PDF (Nextcloud 20.0.7): https://cloud.nendzynski.de:8443/index.php/s/o49EBjHoe78GQEj

Working Link:
Direckt link to the shared file (Nextcloud 20.0.7): https://cloud.nendzynski.de:8443/index.php/s/axZmsGMPXQyiNcX

Shared folder contains a PDF (Nextcloud 20.0.5): https://home.gonline.at:4443/s/BEp93ifzebQ7Frj?

@koarlmichael
Copy link

Can confirm, since update to 20.0.6 and 20.0.7 shared folders with PDF dont work.

@jakieu
Copy link

jakieu commented Feb 4, 2021

I can confirm this, too. When logged in, I can open PDF files perfectly fine. Opening the same folder as a shared link (not logged in to nextcloud), the following error occurs:

PDF.js v2.4.456 (build: 228a591c)
Message: Invalid PDF structure.

I've updated from 20.0.4 to 20.0.7 today.

@daukus
Copy link

daukus commented Feb 4, 2021

Can confirm that, too. Pdf files cannot be opened when are shared by a public link, in a shared folder.

Capture

@megothub
Copy link

megothub commented Feb 5, 2021

+1
It works when you are logged in.
But, it doesn't work for public shares. Even on password protected shares

On my side Latest NC 20.0.7
Ubuntu 20.04.2

The only workaround is to disable PDF Viewer

@Hanskes
Copy link

Hanskes commented Feb 5, 2021

same problem here, since update to 20.0.7

@bene33
Copy link

bene33 commented Feb 7, 2021

+1

@chthal
Copy link

chthal commented Feb 8, 2021

Same here after Upgrade to 20.0.7. Nextclouds log says: "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you." But resharing the file again does not change anything.

@dsiminiuk
Copy link

+1

@nderambure
Copy link

This is the same bug than here : #207

@dsiminiuk
Copy link

@nderambure Not exactly as described in #207.

I experience this issue only when opening a PDF file from a shared folder. Links made directly to the same PDF open fine. Also it was working up to v20.0.5 and now in 20.0.7 it does not.

That does not mean it is not the same bug, I just can't say it is based on the description in #207.

@nderambure
Copy link

nderambure commented Feb 8, 2021

It's just an attempt to "wake up" this bug for centralizing effort ;)

@wankdanker
Copy link

I'm pretty sure that this issue was introduced in commit c992b55.

The new encodedDavPath function introduced in that commit splits the URL on '/' and then calls encodeURIComponent on each element of the array. The code doesn't have special handling for query string arguments.

This URL:

https://nextcloud.example.com/index.php/ohxie9ba1ii5AeS/download?path=/&files=Test.pdf

Splits into the following chunks:

  • https:
  • nextcloud.example.com
  • index.php
  • ohxie9ba1ii5AeS
  • download?path=
  • &files=Test.pdf

Each chunk is encodeURIComponent()ed and concatenated to the final URL.

  • https%3A
  • nextcloud.example.com
  • index.php
  • ohxie9ba1ii5AeS
  • download%3Fpath%3D
  • %26files%3DTest.pdf

Result:

https://nextcloud.example.com/index.php/ohxie9ba1ii5AeS/download%3Fpath%3D/%26files%3DTest.pdf

This path does not exist in the server and the server issues a 302 redirect to the login page.

@szaimen
Copy link
Collaborator

szaimen commented Feb 9, 2021

cc @danxuliu

wankdanker added a commit to wankdanker/files_pdfviewer that referenced this issue Feb 10, 2021
In nextcloud#286, users have reported that PDF files
are not viewable via public share links. The issue was introduced in
c992b55 when attempting to encode parts of the URL for files that
have special characters.

This patch uses the URL Web API to deal with the parts of the URL
in a more specific way. Also, the path and files searchParams are
set based on `this.filename` and `this.basename` in the same way
it is done in the View module when setting `davPath`.

This has been tested on private and shared public links on files
with and without special characters.
wankdanker added a commit to wankdanker/files_pdfviewer that referenced this issue Feb 10, 2021
In nextcloud#286, users have reported that PDF files
are not viewable via public share links. The issue was introduced in
c992b55 when attempting to encode parts of the URL for files that
have special characters.

This patch uses the URL Web API to deal with the parts of the URL
in a more specific way. Also, the path and files searchParams are
set based on `this.filename` and `this.basename` in the same way
it is done in the View module when setting `davPath`.

This has been tested on private and shared public links on files
with and without special characters.
@pongraczi
Copy link

pongraczi commented Feb 10, 2021

Thanks, we also affected by this issue.
Does it worth to patch our system with your commit to fix this issue asap?

@prongi15
Copy link

prongi15 commented Feb 16, 2021

I (on NC 20.0.7) experience the same Issue: I cannot open PDFs that are stored within a publicly shared folder. Results in this error:
Bildschirmfoto 2021-02-16 um 08 01 20

NC gives this error in the log:

[index] Error: Exception: The requested uri(FILENAME) cannot be processed by the script '/index.php/s/8wk7HSYqzXcBnyd/download?path=/&files=FILENAME.pdf') at <>

  1. /var/www/vhosts/NC-ADRESS/httpdocs/nextcloud/lib/base.php line 951
    OC\AppFramework\Http\Request->getRawPathInfo()
  2. /var/www/vhosts/NC-ADRESS/httpdocs/nextcloud/index.php line 37
    OC::handleRequest()

GET /index.php/s/8wk7HSYqzXcBnyd/download%3Fpath%3D/%26files%3DFILENAME.pdf
from XXX.138.203.182 by User at 2021-02-16T07:27:37+00:00
(removed personal info from the log)

Download of the same PDF-file works. Also, if I share the PDF individually, it does open.
A solution would be highly appreciated. Also, of course, thank you for the great work with this app!

@pierre-alain-b
Copy link

Same issue here. Without knowing how to patch with #309, I circumvented temporarily the problem by disabling the PDFViewer in the list of apps. At least users do not complain anymore!

@skjnldsv
Copy link
Member

#319

@fuco809
Copy link

fuco809 commented Feb 24, 2021

behaviour seems to match this old bug nextcloud/server#19572

@ainola
Copy link

ainola commented Feb 24, 2021 via email

@cjhille
Copy link

cjhille commented Jun 25, 2021

The newest release of NC 21 has this fixed for me.

@skjnldsv
I'm on 21.0.2 and the issue still persists for me. Any path with a character that gets transformed by encodeURI (e.g. a space or bracket) will cause the loading of the PDF to fail as described by @wankdanker

Can you reopen the issue?

@szaimen
Copy link
Collaborator

szaimen commented Jun 25, 2021

see #381 (comment)

@cjhille
Copy link

cjhille commented Jun 25, 2021

Oh, I see. The fix didn't make it in 21.0.2. The manual patch works fine. Thank you for your support 🙏

@Bugsbane
Copy link
Member

This issue still seems to exist (or has been brought back by a regression) in Nextcloud 28.0.4.

Sharing a link to a PDF (set to editable) won't even show the PDF to someone not logged in. If logged in it shows fine. If special characters are removed from the file name (in this case hyphens), it works fine. Special characters don't seem to matter in preceding folders.

Do we need to reopen this, or is this considered a new issue? The symptoms certainly seem to still be the same.

@bjo81
Copy link

bjo81 commented Apr 21, 2024

I already created a new issue in #946

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests