Skip to content

[Bug]: No clipboard access for non-https NextCloud servers #40666

@smarinier

Description

@smarinier

⚠️ This issue respects the following points: ⚠️

Bug description

Most "copy to clipboard" operations are made using directly the navigator.clipboard:

e.g. : await navigator.clipboard.writeText(this.internalLink)

In fact, navigator.clipboard is "undefined" when nextcloud is not "secured" (https) in modern browsers (Chrome and Firefox). This generates an exception, without user feedback (Sharing Internal Link at least).

I don't think "https" is one prerequisite for NC. And in my case (developer on NextCloud and family user with my local server), i didn't always configure with an auto-generate certificate! (which implies an annoying warning from the browsers).

Don't you think this could be embeded in a function verifying the availability of navigator.clipboard (and may offer the workaround of textarea + document.execCommand('copy') ?

Steps to reproduce

  1. Use a local Nextcloud on http
  2. Go to Files and select Share icon
  3. Try to copy the internal Link

Expected behavior

Error in developer console:

TypeError: navigator.clipboard is undefined
e SharingEntryInternal.vue:87
d runtime.js:24
t runtime.js:267
_ runtime.js:84
Z SharingEntrySimple.vue:20
s SharingEntryInternal.vue:101
copyLink SharingEntryInternal.vue:101
copyLink SharingEntryInternal.vue:101
copyLink SharingEntryInternal.vue:101
click SharingEntryInternal.vue:1
click NcActions.js:2
VueJS 2
click NcActions.js:2
VueJS 63
r files_sharing_tab.js:69

Installation method

Community Manual installation with Archive

Nextcloud Server version

26

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

SQlite

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "sqlite3",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.0.13"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "version": "26.0.7.0",
        "overwrite.cli.url": "http:\/\/192.168.0.13\/nc26\/",
        "installed": true
    }
}

List of activated Apps

Enabled:
  - activity: 2.18.0
  - circles: 26.0.0
  - cloud_federation_api: 1.9.0
  - comments: 1.16.0
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.1
  - files_mindmap: 0.0.29
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - nextcloud_announcements: 1.15.0
  - notifications: 2.14.0
  - oauth2: 1.14.1
  - password_policy: 1.16.0
  - photos: 2.2.0
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - recommendations: 1.5.0
  - related_resources: 1.1.0
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - support: 1.9.0
  - survey_client: 1.14.0
  - systemtags: 1.16.0
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - admin_audit: 1.16.0
  - bruteforcesettings: 2.6.0
  - encryption: 2.14.0
  - files_external: 1.18.0
  - suspicious_login: 4.4.0
  - twofactor_totp: 8.0.0
  - user_ldap: 1.16.0

Nextcloud Signing status

File not found

Nextcloud Logs

{"reqId":"YsJHdVm6vtZWbw9Q2LFb","level":3,"time":"2023-09-27T08:46:08+00:00","remoteAddr":"192.168.0.10","user":"admin","app":"index","method":"POST","url":"/nc26/index.php/apps/text/session/sync","message":"OCA\\Text\\Service\\DocumentService::getFileForSession(): Argument #1 ($session) must be of type OCA\\Text\\Db\\Session, bool given, called in /var/www/html/nc26/apps/text/lib/Service/ApiService.php on line 232 in file '/var/www/html/nc26/apps/text/lib/Service/DocumentService.php' line 442","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36","version":"26.0.7.0","exception":{"Exception":"Exception","Message":"OCA\\Text\\Service\\DocumentService::getFileForSession(): Argument #1 ($session) must be of type OCA\\Text\\Db\\Session, bool given, called in /var/www/html/nc26/apps/text/lib/Service/ApiService.php on line 232 in file '/var/www/html/nc26/apps/text/lib/Service/DocumentService.php' line 442","Code":0,"Trace":[{"file":"/var/www/html/nc26/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nc26/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/html/nc26/lib/base.php","line":1065,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/html/nc26/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/html/nc26/lib/private/AppFramework/Http/Dispatcher.php","Line":169,"Previous":{"Exception":"TypeError","Message":"OCA\\Text\\Service\\DocumentService::getFileForSession(): Argument #1 ($session) must be of type OCA\\Text\\Db\\Session, bool given, called in /var/www/html/nc26/apps/text/lib/Service/ApiService.php on line 232","Code":0,"Trace":[{"file":"/var/www/html/nc26/apps/text/lib/Service/ApiService.php","line":232,"function":"getFileForSession","class":"OCA\\Text\\Service\\DocumentService","type":"->"},{"file":"/var/www/html/nc26/apps/text/lib/Controller/SessionController.php","line":92,"function":"sync","class":"OCA\\Text\\Service\\ApiService","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nc26/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"sync","class":"OCA\\Text\\Controller\\SessionController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nc26/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nc26/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nc26/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/html/nc26/lib/base.php","line":1065,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/html/nc26/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/html/nc26/apps/text/lib/Service/DocumentService.php","Line":442},"CustomMessage":"--"}}

Additional info

Firefox : 118.0
Google Chrome: 117.0.5938.92

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions