Bug 136836 - testcase - selectedTextAsHTML() does not return html element as claimed in api docs
Summary: testcase - selectedTextAsHTML() does not return html element as claimed in ap...
Status: CONFIRMED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-04 19:00 UTC by Gary Cramblitt
Modified: 2021-03-21 15:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
0x54DD58CF23AAAFB0.asc (4.83 KB, application/pgp-keys)
2021-03-21 15:17 UTC, Gary Cramblitt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Cramblitt 2006-11-04 19:00:46 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
Compiler:          g++ (GCC) 4.1.2 20061028 (prerelease) (Debian 4.1.1-19) 
OS:                Linux

The following code fragment in the KTTS Konqueror plugin returns markup that is missing the <html> element.  Instead, it contains the DOCTYPE followed by <body> element.

KHTMLPart *part = (KHTMLPart *) parent();
part->selectAll();
query = part->selectedTextAsHTML();
// Restore no selection.              part->setSelection(part->document().createRange());

The API docs for selectedTextAsHTML claim the returned string will have the html element.

Here is the web page source I happened to be experimenting with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
<meta name="http-equiv" content="text/html; charset=UTF-8" />
<title>Simple Q Test</title>
<meta name="author" content="Benjamin Hawkes-Lewis" />
</head>
<body>
<h1>Simple Q Test</h1>
<p>Markup only: <q>Hi there.</q></p>
<p>Markup plus superfluous punctuation: "<q>Hi there.</q>"</p>
<p>Punctuation only: "Hi there."</p>
</body>
</html>

The string returned from selectedTextAsHTML follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <body><H1>Simple Q Test</H1> <P>Markup only: <Q>Hi there.</Q></P> <P>Markup plus superfluous punctuation: "<Q>Hi there.</Q>"</P> <P>Punctuation only: "Hi there."</P></body>

Browsing the KHTMLPart code, it appears that my call to part->selectAll() is the cause.  Is there a simple way I can select all of the document so that selectedTextAsHTML() would include the html element?
Comment 1 Justin Zobel 2021-03-21 00:25:37 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 10 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 2 Gary Cramblitt 2021-03-21 15:17:25 UTC
Created attachment 136919 [details]
0x54DD58CF23AAAFB0.asc

Wow, this was certainly a blast from the past!

Unfortunately, I don't use KDE any more; haven't for years, so I can't
say if the bug still exists or not.  It used to impact the accessibility
plugin in Konqueror, but I doubt that is an issue any more.  In all
likelihood, you can close the bug as "Overcome by Events (OBE).

And I couldn't log into bugzilla anymore; hence this attempt to reply to
you.

Thank you for all the hard work you and all the contributors put into
KDE.  It is an awesome desktop.

Best regards