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

Pasting pretty much anything from web pages does not work #849

Closed
rpallai opened this issue Feb 10, 2023 · 4 comments
Closed

Pasting pretty much anything from web pages does not work #849

rpallai opened this issue Feb 10, 2023 · 4 comments
Assignees
Labels
bug/fix Quaternion doesn't work as expected

Comments

@rpallai
Copy link
Contributor

rpallai commented Feb 10, 2023

It almost always leads to "invalid or unsupported" error message.

In the worst case the plain text version should be inserted.

@KitsuneRal KitsuneRal added the bug/fix Quaternion doesn't work as expected label Feb 12, 2023
@berrange
Copy link

I'm seeing the same problem with pasting pretty much any text from firefox.

For context, I'm using quaternion-0.0.95.1-3.fc37.x86_64 on Fedora 37 login session with GNOME Desktop plus Wayland.

My workaround is to paste the text from firefox into a terminal or editor, then copy it again and paste into quaternion.

rpallai added a commit to rpallai/Quaternion that referenced this issue Feb 17, 2023
Many people like pasting plain text as there is less trouble with
it and does the job. Even Element pastes plain text by default
despite of being a rich client. This is why this patch switches to
plain text pasting by default while makes it configurable.

Other version can be pasted by `Ctrl+Shift+V`.

Cc quotient-im#849
rpallai added a commit to rpallai/Quaternion that referenced this issue Feb 20, 2023
Many people like pasting plain text as there is less trouble with
it and does the job. Even Element pastes plain text by default
despite being a rich client. This is why this patch switches to
plain text pasting by default while makes it configurable.

Other version can be pasted by `Ctrl+Shift+V`.

Cc quotient-im#849
@berrange
Copy link

FYI, experimenting I see two common scenarios.

The first case which I hit 90% of the time is that the text I'm pasting simply has no HTML elements present, eg because I've just selected some text from the middle of a paragraph

In this case quaternion prints this on the stderr:

"Invalid XHTML: Diff selection: mark the radio boxes of the versions to compare and hit enter or the button at the bottom.
Error at char 1: "Start tag expected."
Buffer at error: iff selection: mark the radio boxes of the versions to compare and hit enter or the button at the bottom.
HTML insertion failed at pos 1 with error "Start tag expected."

So the HTML parser is not seeing any start tag and thus considers it invalid HTML.

IMHO this is simply and plainly broken. Any bare text should be considered valid HTML.

The less common case is where the text I've selected in the browser is not well formed because it lacks correct opening/closing tag pairs. I've see the browser emit such code when selecting text that crosses sections of the page - some opening or closing tags may get omitted depending on where I've started or ended the text selection..

From the POV of parsing the pasted text, it is understandable that the HTML parser be unhappy with this, and it is somewhat tricky to reconcile. None the less, as a user I feel like we should still be able to paste the selected text into a message. Almost any other app successfully pastes the text in this scenario, because they simply ask the original paste selection owner for the text/plain version rather than the text/html version,and the browser is happy to supply the plain text with the mis-matched tags omitted. I feel like if HTML parsing fails, it would be better to request the selection as plain text and paste that, rather than rejecting it

@ghost
Copy link

ghost commented May 12, 2023

Mismatched tags are also valid in many cases in html, just not in xhtml. The parser basically'd need to parse html and not xhtml :)

@KitsuneRal KitsuneRal self-assigned this Jul 23, 2023
@KitsuneRal
Copy link
Member

KitsuneRal commented Jul 23, 2023

@berrange thanks for the investigation. The first case was indeed caused by a blunder and will be fixed shortly. And I agree that reverting to the plain text version with feedback about it in the status bar is a good approach for the second case.

@nephele-gh XHTML is what Quaternion converts HTML to, internally. If you know a good lightweight Qt-based HTML parser, let me know.

@KitsuneRal KitsuneRal moved this to Version 0.0.96 - Done in Quaternion 1 Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/fix Quaternion doesn't work as expected
Projects
Status: Version 0.0.96 - Done
Development

No branches or pull requests

3 participants