Comments (16)
Changed
var url = input().text()
to
var url = input()
The error has also changed:
Warning [2023-10-29 01:07:17.030] <Server-18540>: [default] QtWarning: ShellExecute 'https://github.com/hluk/CopyQ/issues/2084%00' failed (error 2).
But if I explicitly insert the URL into the code, like this
var url = 'https://github.com/hluk/CopyQ/issues/2084'
then this URL opens in the browser without any problems.
from copyq.
Through trial and error, it was found that if the link is opened in this format
var url = 'https://github.com/hluk/CopyQ/issues/2084'
then everything works as it should, i.e. the browser page opens with this link.
But in this case
var url = 'https://github.com/hluk/CopyQ/issues/2084%00'
gives an error
Warning [2023-10-29 03:00:10.915] <Server-18540>: [default] QtWarning: ShellExecute 'https://github.com/hluk/CopyQ/issues/2084%00' failed (error 2).
So, in some incomprehensible way, %00
is added to the link at the end.
from copyq.
@hluk
Hi.
I want to clarify the situation from the very beginning.
There are 2 scripts taken from the following topic "Bug or feature ?" #1100
- Add URL label & Add URL label (Edge) #1100 (comment)
Add URL label & Add URL label (Edge) (click to open)
[Commands]
1\Automatic=true
1\Command="
copyq:
removeData('text/x-moz-url-priv')
setData(mimeItemNotes, input())"
1\Icon=\xf15b
1\Input=text/x-moz-url-priv
1\Name=Add URL label
2\Automatic=true
2\Command="
copyq:
removeData('application/x-qt-windows-mime;value=\"msSourceUrl\"')
setData(mimeItemNotes, input())"
2\Icon=\xf15b
2\Input="application/x-qt-windows-mime;value=\"msSourceUrl\""
2\Name=Add URL label (Edge)
size=2
- Open in &Browser #1100 (comment)
Open in &Browser (click to open)
[Command]
Command="
copyq:
var url = input().text()
if ( open(url) )
popup('Opening URL', url)
else
popup('Failed to open URL', url)"
HideWindow=true
Icon=\xf0ac
InMenu=true
Input=application/x-copyq-item-notes
Name=Open in &Browser
So, for some unknown reason, the script Add URL label & Add URL label (Edge) adds %00
at the end of the URL when adding it to the mimeItemNotes of the clip.
I found a solution - before saving to mimeItemNotes, use the chop(1)
command to remove this last character before saving.
[Command]
Name=Add URL label
Command="
copyq:
removeData('text/x-moz-url-priv')
var url = input()
url.chop(1)
setData(mimeItemNotes, url)"
Input=text/x-moz-url-priv
Automatic=true
Icon=\xf15b
But most likely there is some bug in CopyQ, which is causing such behavior. Therefore, it would be better if the error itself is fixed, rather than using such workarounds.
from copyq.
Changed
var url = input().text()
to
var url = input()
There is no attribute text
for ByteArray
(the return type of input()
). Your fixed code looks OK.
But in this case
var url = 'https://github.com/hluk/CopyQ/issues/2084%00'
gives an errorWarning [2023-10-29 03:00:10.915] <Server-18540>: [default] QtWarning: ShellExecute 'https://github.com/hluk/CopyQ/issues/2084%00' failed (error 2).
So, in some incomprehensible way,
%00
is added to the link at the end.
It looks like the original data contains trailing null character. I can reproduce this from shell:
# Web browser opens: https://github.com/hluk/CopyQ/issues/2520%00
❯ printf "%s\0" "https://github.com/hluk/CopyQ/issues/2520" | copyq 'open(input())'
true
# ByteArray with null character converted to string still contains the null (bellow is the hexadecimal representation of the string)
❯ printf "HELLO\0" | copyq 'str(input())' | xxd
00000000: 4845 4c4c 4f00 0a HELLO..
# Here is the input without null
❯ printf "HELLO" | copyq 'str(input())' | xxd
00000000: 4845 4c4c 4f0a HELLO.
It seems that the following works well, provided the input is in Latin1 encoding (the standard ISO 8859-1 character set):
var url = input().toLatin1String()
The question is why the item note contains the null character. I assume that the clipboard content might have been misinterpreted by CopyQ or the underlying Qt framework (which handles most of the clipboard data transformations/representation).
Which app did you copy the URL from?
from copyq.
I didn't copy the URLs themselves, I copied the texts from the aforementioned Firefox, Edge and Chrome and after that "Add URL label & Add URL label (Edge)" did all the rest of the work on adding URLs to the "Note" fields of the clips.
from copyq.
I cannot reproduce the trailing null character when copying from Firefox. I think this could be a problem in the source application. Probably not worth adding a workaround in CopyQ for this.
from copyq.
Let me know if you can reproduce it (and how) when copying from the source app. I would prefer to have a proper fix in CopyQ if that will be possible.
from copyq.
Here is the most common process of copying text in Firefox:
CopyQ-Copying-NULL-Video_2023-10-31_162525.webm
from copyq.
Oh, the item notes with URL are created automatically with a command. Can you share the command code here with "Copy Selected" button?
BTW, thanks for posting the screencasts - very useful!
from copyq.
Under the "Copy Selected" button, do you mean this one?
This is an external application - SnipDo, an analogue of Popclip on MacOS.
All the work is done by CopyQ using the two scripts I mentioned above #2520 (comment)
BTW, thanks for posting the screencasts - very useful!
You are welcome, and thank you for your work, and I, as a user, just try to convey information about the problem as clearly as possible so as not to force you to develop telepathy as well.
from copyq.
I mean this process: https://copyq.readthedocs.io/en/latest/faq.html#how-to-load-shared-commands-and-share-them
To share your commands, you can select the commands from command list in “Commands” dialog and press “Copy Selected” button (or just hit Ctrl+C).
And paste the command into a comment in this issue.
from copyq.
Oh, I see.
This is what works in Firefox, but not in Edge and Chrome.
[Command]
Name=Add URL label
Command="
copyq:
removeData('text/x-moz-url-priv')
var url = input()
url.chop(1)
setData(mimeItemNotes, url)"
Input=text/x-moz-url-priv
Automatic=true
Icon=\xf15b
This one, which supposed to work in Edge and Chrome, doesn't work in either of them.
[Command]
Name=Add URL label (Edge)
Command="
copyq:
removeData('application/x-qt-windows-mime;value=\"msSourceUrl\"')
setData(mimeItemNotes, input())"
Input="application/x-qt-windows-mime;value=\"msSourceUrl\""
Automatic=true
Icon=\xf15b
PS. Please take a look at my screencast on the more troubling issue of not being able to copy images from browsers.
#2084 (comment)
from copyq.
I tested it on Linux with Firefox 118.0.2 and there is no trailing null character in the URL:
❯ copyq clipboard text/x-moz-url-priv|xxd
00000000: 6874 7470 733a 2f2f 6769 7468 7562 2e63 https://github.c
00000010: 6f6d 2f68 6c75 6b2f 436f 7079 512f 6973 om/hluk/CopyQ/is
00000020: 7375 6573 2f32 3532 30 sues/2520
I also checked Chromium but it does not seem to provide the URL in clipboard. You can check the formats by copying from the web browser and opening Clipboard Content dialog in CopyQ (Ctrl+Shift+C).
from copyq.
It seems, this command doesn't work in Windows.
Regarding trailing NULL in URLs
As you can see, the trailing NULL character appears before the URL is recorded into Note. (application/x-copyq-item-notes
)
PS. I apologize, but I didn't quite understand what was meant by
You can check the formats by copying from the web browser and opening Clipboard Content dialog in CopyQ (Ctrl+Shift+C).
I have the following information displayed in this window.
CopyQ-Clipboard-Contnet-formats-Video_2023-11-01_182429.webm
from copyq.
It seems, this command doesn't work in Windows.
The console output on Windows does not work for GUI apps unfortunately (#349).
You can use the Action dialog (F5 shortcut) in CopyQ instead with "Store standard output" set to "text/plain" to store the command output to new item.
PS. I apologize, but I didn't quite understand what was meant by
You can check the formats by copying from the web browser and opening Clipboard Content dialog in CopyQ (Ctrl+Shift+C).
More specifically: Use the Clipboard Content to figure out the format name containing URL for the current system clipboard content visible by CopyQ. It should list text/x-moz-url-priv
for stuff copied from web pages in Firefox.
from copyq.
CopyQ-Notes-issue-Video_2023-11-03_014635_part1.webm
CopyQ-Notes-issue-Video_2023-11-03_014635_part2.webm
from copyq.
Related Issues (20)
- Paste in pycharm is unreliable [linux][Focus issue] HOT 2
- v9 and RDP: Remote machine does not see copied items from local machine HOT 2
- Copyq not working when copying in private browsing (firefox) HOT 2
- Does not start. HOT 3
- Copyq icon does not show in panel. HOT 1
- wl-copy in wsl no longer displays in clipboard history on copyq version 9.0.0 HOT 4
- Weird flickering of items and menus. HOT 1
- Copyq disappears when I click on it HOT 1
- Does not work with Wayland (ok switching to X11) HOT 1
- inconsistent search selection
- Command "Ignore *"Password"* window" doesn't work HOT 6
- Manually editing the contents of the Item Content window
- Wish to optimize multi-device data synchronization
- How can I disable text/plain;charset=utf-8 ?
- Add an option to append to the clipboard based on an alt C or other key press HOT 2
- CopyQ v8 and v9 crash often HOT 5
- v8 and v9 are not working on macos 14.5 HOT 6
- CopyQ v9 sometimes fails to copy HOT 4
- #2679, #2680 break copying from private/incognito windows on Windows HOT 4
- Calling onTabSelected() breaks tab switching HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copyq.