Bug 141512 - com.sun.star.system.SystemShellExecute does not correctly process paths with wildcards
Summary: com.sun.star.system.SystemShellExecute does not correctly process paths with ...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.0.1.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-06 11:23 UTC by joesch04
Modified: 2021-04-06 13:17 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Extension to reproduce the Bug (see description in the Bug-report) (195.77 KB, application/vnd.openofficeorg.extension)
2021-04-06 11:26 UTC, joesch04
Details

Note You need to log in before you can comment on or make changes to this bug.
Description joesch04 2021-04-06 11:23:53 UTC
Description:
Since LO 7.x, paths with wildcards are no longer processed correctly by "com.sun.star.system.SystemShellExecute".

As an example you can install mottco (http://calc-info.de/files/mottco_200.oxt) and call the button "Hilfe/Über....--->Dokumentation anzeigen" there, which starts the following macro:

Sub help_call()
	Dim aService
	Dim pdf_directory
	
	aService = GetDefaultContext().getByName("/singletons/com.sun.star.deployment.PackageInformationProvider") 
	pdf_directory = aService.getPackageLocation("org.joesch.mottco") & "/mottco/"
	If FileExists(ConvertToUrl(pdf_directory & "mottco_help.pdf")) Then
			Dim start as object
			start = createUnoService("com.sun.star.system.SystemShellExecute")
			start.execute(ConvertToUrl(pdf_directory & "mottco_help.pdf"), "", 0)
		Else
			MsgBox ("The help file was not found." ,16, "Help file not available")
			Exit Sub
	End If
End Sub

Up to LO 6.x this worked correctly, since 7.x it gives the following error message:
"file:///E:/LO_710/LibreOfficePortable/App/libreoffice/program/../../Data/settings/user/uno_packages/cache/uno_packages/lu7860nw7fts.tmp_/mottco_200.oxt could not be found [...]"

In "FileExists( ..." the path is evaluated correctly here, because the following returns "True":

aService = GetDefaultContext().getByName("/singletons/com.sun.star.deployment.PackageInformationProvider") 
pdf_directory = aService.getPackageLocation("org.joesch.mottco") & "/mottco/"
Msgbox FileExists(ConvertToUrl(pdf_directory & "mottco_help.pdf"))



Steps to Reproduce:
1.install http://calc-info.de/files/mottco_200.oxt
2.run: Hilfe/Über....--->Dokumentation anzeigen
3.

Actual Results:
you get the error message (example):  
"file:///E:/LO_710/LibreOfficePortable/App/libreoffice/program/../../../Data/settings/user/uno_packages/cache/uno_packages/lu7860nw7fts.tmp_/mottco_200.oxt konnte nicht gefunden werden [...]"

Expected Results:
The path should be correctly detected and a PDF file should be opened


Reproducible: Always


User Profile Reset: Yes



Additional Info:
The problem is not specific to the extensions named "mottco", this extension is only given as an example because it requires an extension to reproduce the error, since the return of :

aService = GetDefaultContext().getByName("/singletons/com.sun.star.deployment.PackageInformationProvider") 
	pdf_directory = aService.getPackageLocation("org.joesch.mottco") & "/mottco/"

as input value for:

start = createUnoService("com.sun.star.system.SystemShellExecute")
			start.execute(ConvertToUrl(pdf_directory & "mottco_help.pdf"), "", 0)

is needed, because in the returned path for .getPackageLocation, the placeholder "/../../../" occurs.
Comment 1 joesch04 2021-04-06 11:26:43 UTC
Created attachment 170978 [details]
Extension to reproduce the Bug (see description in the Bug-report)
Comment 2 Mike Kaganski 2021-04-06 12:25:35 UTC
A small correction: ".." is not a wildcard, but a relative path element.

(In reply to joesch04 from comment #0)
> Since LO 7.x, paths with wildcards are no longer processed correctly by
> "com.sun.star.system.SystemShellExecute".

In fact, this is not true. The URL is passed unchanged to the ShellExecuteExW, and this is the limitation of *system* call that it disallows the relative parts in the URL.

IMO this is NOTABUG, and was working previously just by accident, because LibreOffice had pre-processed the URL (and that was wrong, since the idea behind XSystemShellExecute::execute is pass the argument to system shell unchanged).

The author of the extension (Jorg) likely should use a call to ConvertFromURL [1] and pass the system path to the execute() call, which would succeed.

Stephan could correct me if I am wrong here; adding him to CC.

[1] https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03120313.html
Comment 3 Mike Kaganski 2021-04-06 12:28:09 UTC
(In reply to Mike Kaganski from comment #2)
> this is the limitation of *system* call that it
> disallows the relative parts in the URL.

For test, try to use system's Run (Windows key + R) and run the failing URL there. The result would be exactly the same error message.
Comment 4 joesch04 2021-04-06 13:07:24 UTC
> A small correction: ".." is not a wildcard

yes, that's right. I had forgotten the correct term.

> The author of the extension (Jorg) likely should use a 
> call to ConvertFromURL [1] and pass the system path to 
> the execute() call, which would succeed.

mmh ... embarrassing for me [*], because I have to say: 'it's not a bug, it's my stupidity'.

You are absolutely right, using "ConvertFromURL" fixes the problem AND in the idl reference the usage of the path parameter is described meticulously correct [**]. 
The wrong use of "ConvertToURL" exists in "mottco" ready 10 years for sure :-( 


[*]
I myself, am "Jörg" - "joesch" is the abbreviation for "Jörg Schmidt".

[**]
https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1system_1_1XSystemShellExecute.html
Comment 5 Mike Kaganski 2021-04-06 13:17:12 UTC
(In reply to joesch04 from comment #4)
> mmh ... embarrassing for me [*], because I have to say: 'it's not a bug,
> it's my stupidity'.

We all make mistakes; errare humanum est :-)

> [*]
> I myself, am "Jörg" - "joesch" is the abbreviation for "Jörg Schmidt".

Nice to meet you!