Bug 157162 - Blank character in LibreOffice installation directory leads to error message when bootstrapping from Python script
Summary: Blank character in LibreOffice installation directory leads to error message ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
7.6.0.3 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-08 22:44 UTC by Hossein
Modified: 2024-03-15 08:51 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
A sample Python scripts that uses bootstrap() method (191 bytes, text/plain)
2023-09-08 22:44 UTC, Hossein
Details
Screenshot of error dialog box, which says soffice.exe does not exist (18.73 KB, image/png)
2023-09-08 22:45 UTC, Hossein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2023-09-08 22:44:20 UTC
Created attachment 189444 [details]
A sample Python scripts that uses bootstrap() method

Description:
Having a blank character in LibreOffice installation directory leads to the display of an error message when bootstrapping from Python script. This is specially important on Windows where this is the default situation. The default Windows installation is in "C:\Program Files\LibreOffice", which contains a space character.

Steps to Reproduce:
1. Download start.py from the attachment
1. Go to some folder, for example c:\windows\tmp
2. Run this command:
 "c:\Program Files\LibreOffice\program\python.exe" start.py
If start.py is somewhere else, give the correct path.

Actual Results:
Dialog box, showing something like this:
c:\Windows\Temp\Files\LibreOffice\program\soffice.exe does not exist.

This string (wrong path) consists of:

1) Current working directory
2) Path to Python binary, cut after space character
3) soffice.exe

The error dialog box says the soffice.exe (within the wrong path) does not exist. This shows that soffice.exe is called with wrong parameters, so that it wrongly assumes that this the above string is a file to open, and it gives error that it does not exist.
It seems that the parameter handling routines do not care well enough about the possible space characters in the path.

Expected Results:
Invoking soffice.exe should happen with the correct parameters, and the error dialog box should not appear.

Reproducible: Always


User Profile Reset: No


Additional Info:
Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265
CPU threads: 20; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

A workaround is using short names, where applicable. For example, on Windows one can invoke:

 "c:\Progra~1\LibreOffice\program\python.exe" start.py

In this case, the error dialog does not come up.
Comment 1 Hossein 2023-09-08 22:45:53 UTC
Created attachment 189445 [details]
Screenshot of error dialog box, which says soffice.exe does not exist
Comment 2 Werner Tietz 2023-09-09 17:37:46 UTC
You are barking the wrong tree…
This is neither a bug of Libreoffice nor python.
Comment 3 Hossein 2023-09-09 22:36:06 UTC
(In reply to Werner Tietz from comment #2)
> You are barking the wrong tree…
> This is neither a bug of Libreoffice nor python.
1) In the bug report it is stated that the problem is from the "LibreOffice SDK", and not the LibreOffice program itself or even Python.
2) If you claim it is not a correct bug filing, you have to describe what you mean exactly, pointing to the possible problems.

3) In simple words, to reproduce the problem, you only have to run the internal python, and then invoke bootstrap() function:

C:\>"c:\Program Files\LibreOffice\program\python.exe"
Python 3.8.17 (default, Aug  9 2023, 17:36:19) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import officehelper
>>> officehelper.bootstrap()

And you will see the error message.
Comment 4 Buovjaga 2023-09-11 10:54:59 UTC
(In reply to Hossein from comment #3)
> C:\>"c:\Program Files\LibreOffice\program\python.exe"
> Python 3.8.17 (default, Aug  9 2023, 17:36:19) [MSC v.1929 64 bit (AMD64)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import officehelper
> >>> officehelper.bootstrap()
> 
> And you will see the error message.

Repro. If using PowerShell, launch with
&("c:\Program Files\LibreOffice\program\python.exe")
Comment 5 Commit Notification 2024-03-02 12:00:57 UTC
Alain Romedenne committed a patch related to this issue.
It has been pushed to "master":

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

tdf#116156 tdf#157162 tdf#159528 Fix glitches in officehelper.py

It will be available in 24.8.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.