Bug 108318 - Copying a hyperlink into a textbox messes up its frame target
Summary: Copying a hyperlink into a textbox messes up its frame target
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Justin L
URL:
Whiteboard: target:24.2.0
Keywords:
: 112962 112963 112964 112965 (view as bug list)
Depends on:
Blocks: Textbox Hyperlink
  Show dependency treegraph
 
Reported: 2017-06-03 09:37 UTC by Bernd Brinker
Modified: 2023-11-01 01:29 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
108318_copyHyperlink.odt: repro 24.2+ (61.88 KB, application/vnd.oasis.opendocument.text)
2023-10-30 18:16 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Brinker 2017-06-03 09:37:44 UTC
Description:
Hello, 

By copying an Hyperlink with Destination '_blank' in a Textbox the String 
"\t"_blank is added at the End of the URL-String and the Hyperlink doesn't work 
fine. 
Thanks. 

Steps to Reproduce:
1.Create an Hyperlink with Destination _blank.
2.Create an Textbox.
3.Copy the Hyperlink in the Textbox. 
4.View the Dialogform for Hyperlink.

Actual Results:  
Hyperlink URL is wrong and doesn't work.

Expected Results:
Hyperlink should not be changed and work fine.


Reproducible: Always

User Profile Reset: No

Additional Info:
[Information automatically included from LibreOffice]
Locale: de
Module: TextDocument
[Information guessed from browser]
OS: Linux (All)
OS is 64bit: yes
Builds ID: LibreOffice 5.3.2.2


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0
Comment 1 Buovjaga 2017-06-10 17:50:24 UTC
Reproduced.

_blank goes to the Frame field, not any nonexistent "destination".

Arch Linux 64-bit, KDE Plasma 5
Version: 5.5.0.0.alpha0+
Build ID: 2802dca10eef67554a81cb2347d5f648fa6fcd63
CPU threads: 8; OS: Linux 4.11; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on June 10th 2017
Comment 2 Xisco Faulí 2017-10-07 08:04:26 UTC
*** Bug 112965 has been marked as a duplicate of this bug. ***
Comment 3 Xisco Faulí 2017-10-07 08:05:59 UTC
*** Bug 112964 has been marked as a duplicate of this bug. ***
Comment 4 Xisco Faulí 2017-10-07 08:06:12 UTC
*** Bug 112963 has been marked as a duplicate of this bug. ***
Comment 5 Xisco Faulí 2017-10-07 08:06:19 UTC
*** Bug 112962 has been marked as a duplicate of this bug. ***
Comment 6 QA Administrators 2018-10-08 02:48:08 UTC Comment hidden (obsolete)
Comment 7 mattia.b89 2019-02-02 22:13:05 UTC
Cannot reproduce the issue, in:

Version: 6.1.4.2
Build ID: 6.1.4-4
CPU threads: 4; OS: Linux 4.20; UI render: default; VCL: gtk3; 
Locale: it-IT (en_GB.UTF-8); Calc: group threaded
Comment 8 Buovjaga 2019-02-03 13:40:51 UTC
Still repro, URL becomes of the form http://www.google.com/" \t "_blank

Arch Linux 64-bit
Version: 6.3.0.0.alpha0+
Build ID: 8fbad2f600cd3ab81e7c1da0e4a2a71ebcac0553
CPU threads: 8; OS: Linux 4.20; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 31 January 2019
Comment 9 QA Administrators 2021-02-03 04:14:27 UTC Comment hidden (obsolete, spam)
Comment 10 QA Administrators 2023-02-04 03:19:52 UTC Comment hidden (obsolete, spam)
Comment 11 Justin L 2023-10-30 18:16:51 UTC
Created attachment 190519 [details]
108318_copyHyperlink.odt: repro 24.2+
Comment 12 Justin L 2023-10-31 16:16:59 UTC
P.S. The same problem is seen pasting this into Calc/Draw/Impress, since they all use EditRTFParser::ReadField(). 

The clipboard is imported as an RTF field, with
aFldInst[HYPERLINK "https://de.wikipedia.org/wiki/LibreOffice" \t "_top" ]
aFldRslt[https://de.wikipedia.org/wiki/LibreOffice]


It is passed to the clipboard as RTF text, so it should be in the format something like 
{\field{\*\fldinst HYPERLINK "http://www.google.com/"}{\fldrslt Google}}
where the field result is the visible text.

I don't see anywhere in the specification where it indicates that other flags can be attached to it for formatting purposes.

However, we do have flags specified for Word's fields.
17.16.5.25 HYPERLINK    Syntax: HYPERLINK field-argument [ switches ]

\l field-argument
text in this switch's field-argument specifies a location in the file, such as a bookmark, where this hyperlink jumps.

\m Appends coordinates to a hyperlink for a server-side image map.

\n Causes the destination site to be opened in a new web browser window.

\o field-argument text in this switch's field-argument specifies the ScreenTip text for the hyperlink.

\t field-argument text in this switch's field-argument specifies the target to which the link should be redirected. Use this switch to link from a frames page to a page that you want to appear outside of the frames page. The permitted values for text are:
 _top, whole page (the default)
 _self, same frame
 _blank, new web browser window
 _parent, parent frame


So the question is, do we have an RTF import problem (need to strip the switches), or is it an export-to-clipboard problem in Writer (where it should not include the switches in RTF's HYPERLINK)?
Comment 13 Justin L 2023-10-31 22:32:48 UTC
It is necessary to export "Target" to RTF, so that LO can import it back in again, since the clipboard is reusing the normal full document RTF export in
sw/source/filter/ww8/rtfattributeoutput.cxx
RtfAttributeOutput::StartURL

This code runs as PASTE time - generating the RTF export on demand.

I don't think that MS Word imports the target though - so it is probably a LO embellishment of the RTF standard.

Things like firefox and kate don't use clipboard RTF, but use
sw/source/uibase/dochdl/swdtflvr.cxx:796: SWTRANSFER_OBJECTTYPE_STRING

BUT - we can avoid the target by checking IsClipboard...
https://gerrit.libreoffice.org/c/core/+/158744


Alternatively, the target could be stripped out during clipboard import, with https://gerrit.libreoffice.org/c/core/+/158743
Comment 14 Commit Notification 2023-11-01 01:28:36 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e8228e0994610fed8af090ff30ffc08bfecb7261

tdf#108318 rtfexport: no hyperlink target for clipboard

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.