server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: `Copy link to clipboard` broken when speeking plain http (https not affected) in 26.0.0.4 (beta 2)

Open ernolf opened this issue 2 years ago • 14 comments

⚠️ This issue respects the following points: ⚠️

  • [X] This is a bug, not a question or a configuration/webserver/proxy issue.
  • [X] This issue is not already reported on Github (I've searched it).
  • [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • [X] Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • [X] I agree to follow Nextcloud's Code of Conduct.

Bug description

After update from 25.0.3.2 to 26.0.04 (beta2), the previous hover-over message for share links Copy to clipboard changed into Copy public link of "Share link" to clipboard and for Internal links it changed into Copy internal link to clipboard but it does not copy the respective link by clicking left mous button as it did before. Using the right mouse button context menu of the browser to copy the link location works though.

Steps to reproduce

  1. Go to sharing details of a random file
  2. Create Share link (not necessary for testing public link behavior)
  3. Test the behavior as described

Expected behavior

Copy link to clipboard with left mouse button, as indicated in the hover-over message

Installation method

Community Manual installation with Archive

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MariaDB

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

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

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

Configuration report

root@nc-test-VM:~# sudo -u www-data php -f /var/www/nextcloud/occ config:list system
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "trusted_domains": [
            "192.168.188.40",
            "192.168.178.40"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "version": "26.0.0.4",
        "check_for_working_htaccess": false,
        "overwrite.cli.url": "http:\/\/192.168.188.40",
        "htaccess.RewriteBase": "\/",
        "dbtype": "mysql",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "updater.release.channel": "beta",
        "updater.secret": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "log_query": false,
        "loglevel": 2
    }
}

List of activated Apps

root@nc-test-VM:~# sudo -u www-data php -f /var/www/nextcloud/occ app:list
Enabled:
  - activity: 2.18.0
  - circles: 26.0.0-beta2
  - 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_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.0
  - 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-alpha1
  - 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.0
  - 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-alpha.0
  - user_ldap: 1.16.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No response

Additional info

I have tested it with this browsers:

  • Brave
  • Chrome
  • Opera

ernolf avatar Feb 07 '23 11:02 ernolf

Cc @Pytal

szaimen avatar Feb 07 '23 11:02 szaimen

Cannot reproduce, what gets copied when clicking on the copy to clipboard buttons @ernolf?

Can you paste your console logs?

Pytal avatar Feb 07 '23 18:02 Pytal

Can you paste your console logs?

SharingEntryLink.vue:781 TypeError: Cannot read properties of undefined (reading 'writeText')
    at SharingEntryLink.vue:772:1
    at d (runtime.js:64:40)
    at Generator.<anonymous> (runtime.js:299:22)
    at Generator.next (runtime.js:124:21)
    at gt (SharePermissionsEditor.vue?f133:20:33)
    at s (SharePermissionsEditor.vue?f133:20:33)
    at SharePermissionsEditor.vue?f133:20:33
    at new Promise (<anonymous>)
    at SharePermissionsEditor.vue?f133:20:33
    at o.copyLink (SharingEntryLink.vue:770:1)
(anonymous) @ SharingEntryLink.vue:781
d @ runtime.js:64
(anonymous) @ runtime.js:299
(anonymous) @ runtime.js:124
gt @ SharePermissionsEditor.vue?f133:20
s @ SharePermissionsEditor.vue?f133:20
(anonymous) @ SharePermissionsEditor.vue?f133:20
(anonymous) @ SharePermissionsEditor.vue?f133:20
copyLink @ SharingEntryLink.vue:770
click @ SharingEntryLink.vue?64e9:1
click @ NcActions.js:2
Ft @ vue.runtime.esm.js:3017
n @ vue.runtime.esm.js:1815
r._wrapper @ vue.runtime.esm.js:7473
SharingEntryInternal.vue:96 TypeError: Cannot read properties of undefined (reading 'writeText')
    at SharingEntryInternal.vue:87:1
    at d (runtime.js:64:40)
    at Generator.<anonymous> (runtime.js:299:22)
    at Generator.next (runtime.js:124:21)
    at F (SharingEntrySimple.vue?cb12:20:33)
    at s (SharingEntryInternal.vue:101:1)
    at SharingEntryInternal.vue:101:1
    at new Promise (<anonymous>)
    at SharingEntryInternal.vue:101:1
    at o.copyLink (SharingEntryInternal.vue:101:1)
(anonymous) @ SharingEntryInternal.vue:96
d @ runtime.js:64
(anonymous) @ runtime.js:299
(anonymous) @ runtime.js:124
F @ SharingEntrySimple.vue?cb12:20
s @ SharingEntryInternal.vue:101
(anonymous) @ SharingEntryInternal.vue:101
(anonymous) @ SharingEntryInternal.vue:101
copyLink @ SharingEntryInternal.vue:101
click @ SharingEntryInternal.vue?6c02:1
click @ NcActions.js:2
Ft @ vue.runtime.esm.js:3017
n @ vue.runtime.esm.js:1815
r._wrapper @ vue.runtime.esm.js:7473

I hope this helps @Pytal 🙏

ernolf avatar Feb 08 '23 08:02 ernolf

Possibly this is the issue then? https://stackoverflow.com/a/71876238

szaimen avatar Feb 08 '23 09:02 szaimen

@ernolf do you use http or https?

szaimen avatar Feb 08 '23 09:02 szaimen

@ernolf do you use http or https?

@szaimen since this is a test environment in a virtual machine, i use http, not https

ernolf avatar Feb 08 '23 09:02 ernolf

So then we have likely found the problem. Can you try with a self signed certificate and https enabled?

szaimen avatar Feb 08 '23 09:02 szaimen

So then we have likely found the problem. Can you try with a self signed certificate and https enabled?

☑️ created self signed cert ☑️ evreything works as expected

ernolf avatar Feb 08 '23 10:02 ernolf

Since this looks like a hard requirement now for https, should we document this behaviour somewhere? Cc @nextcloud/server-frontend

szaimen avatar Feb 08 '23 10:02 szaimen

Depending on the prevalence, we could technically add a utility function to fallback to the deprecated Document.execCommand() method and use the util in place of all the native Clipboard API calls in https://github.com/search?type=code&q=org%3Anextcloud+navigator.clipboard.writeText

Pytal avatar Feb 09 '23 00:02 Pytal

I am not sure about the prevalance but since this is a regression for non-https instances and basically otherwise also a deprecation of them, I'd vote for adding this fallback.

szaimen avatar Feb 09 '23 00:02 szaimen

Also having this problem. 25.0.4

skygunner avatar Mar 18 '23 10:03 skygunner

Same problem on 26.0.0

thejulian avatar Mar 29 '23 10:03 thejulian

Depending on the prevalence, we could technically add a utility function to fallback to the deprecated Document.execCommand() method and use the util in place of all the native Clipboard API calls in https://github.com/search?type=code&q=org%3Anextcloud+navigator.clipboard.writeText

What if we if a do fallback that prints out a "Copying not supported in http mode" or something? Given the big warning about Document.execCommand() on that linked page about deprecation, and that no one is likely going to remember a random detail like "Copying not supported by browsers in http mode" even if they read it in the docs somewhere, maybe an alert message rather than a no-op makes sense. Also avoids adding support via a deprecated fallback that is still going to stop working eventually.

joshtrichards avatar Jun 20 '23 20:06 joshtrichards