Bug 121590 - Unable to alter or delete user fields containing spaces
Summary: Unable to alter or delete user fields containing spaces
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Fields Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2018-11-21 14:13 UTC by libreoffice
Modified: 2023-10-13 03:16 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Document with code and button to reproduce the problem (9.88 KB, application/vnd.oasis.opendocument.text)
2018-11-21 14:13 UTC, libreoffice
Details

Note You need to log in before you can comment on or make changes to this bug.
Description libreoffice 2018-11-21 14:13:28 UTC
Created attachment 146874 [details]
Document with code and button to reproduce the problem

If you create a user field in a macro where the name contains a space, the more fields dialog will not let you edit or delete the field.


Code to reproduce the bug:


vDoc = ThisComponent
sName = "My Field"
If vDoc.getTextFieldMasters().hasByName("com.sun.star.text.FieldMaster.User." & sName) Then
  vField = vDoc.getTextFieldMasters().getByName("com.sun.star.text.FieldMaster.User." & sName)
  vField.Content = "My Field Text"
Else
  vField = vDoc.createInstance("com.sun.star.text.FieldMaster.User")
  vField.Name = sName
  vField.Content = "My Field Text Update"
End If
Comment 1 Oliver Brinzing 2018-11-21 18:42:12 UTC
reproducible, the "name" edit field shows only the first part of the fieldname, e.g. "My" instead "My Field"
Comment 2 Xisco Faulí 2018-11-22 09:57:08 UTC
Reproduced back to

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

The Field dialog doesn't allow to insert spaces.
I guess the solution should be to replace spaces with another char when using macros...
Comment 3 Oliver Brinzing 2018-11-22 17:53:26 UTC
btw: there is a similar issue for named ranges in calc:

inserting named ranges with special characters, e.g. 
operators ':', '+', ... in name are allowed via api
https://bugs.documentfoundation.org/show_bug.cgi?id=119457
Comment 4 Andreas Heinisch 2021-04-29 13:40:20 UTC
According to the documentation in http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1419030_253892949 the name can be any variableName, which is "a string specifying the name of a variable".

The check in the dialog was inserted in the following commit https://github.com/LibreOffice/core/commit/4b920e0b45a42c55503dc03a7297733fb2cfb2a3, but unfortunately I cannot find the mentioned bug.

There even exists a file in https://git.libreoffice.org/core/+/f2039cdbd827d60b8e0dbfa2e1d02dbb276514d6%5E%21 which contains user fields including whitespaces and does get validated using a odf validator.

So we may allow whitespaces, and validate the field name when inserted via api.
Comment 5 Andreas Heinisch 2021-04-29 14:56:14 UTC
The only problem I see is that if a user opens a document containing field names including forbidden characters, they will be silently replaced? The same happens, if they are added via api.
Comment 6 Andreas Heinisch 2021-04-29 18:49:06 UTC
Tested now with a fix which tries to convert all the non allowed characters to underscores, but a couple of test documents contain user fields with special chars like whitespaces, backslashes etc.

Since the ODF allows user fields with strings, mabye we should change just the dialog edit field? Any opinions?
Comment 7 libreoffice 2021-04-29 22:05:14 UTC
Good job guys ... appreciate all your efforts!
Comment 8 libreoffice 2021-05-06 20:13:30 UTC
Just checking for an update and read my last post. Apologies, comes across as patronising which wasn't my intent.
Comment 9 Andreas Heinisch 2021-10-12 07:08:49 UTC
Unfortunately, I cannot decide whether we allow all kind of chars in a user field, and restricting it breaks some existing tests.
Comment 10 libreoffice 2021-10-12 09:55:55 UTC
I believe the text field in the UI should allow the user to change whatever text the field contains. Manipulating the text to satisfy the text fields shortcommings, in my mind, will lead to all kinds of problems.
Comment 11 Andreas Heinisch 2021-10-12 10:02:00 UTC
My problem is what kind of user fields should be allowed and which regressions (display errors arise)? Some examples (without quotes:

"  a user field"
"   "
"@#$%user field"
"Öäüßvşîťë"

The odf-standard defines a user named range as a string which imho allows any combination of chars.
Comment 12 QA Administrators 2023-10-13 03:16:28 UTC
Dear libreoffice,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug