Bug 99742 - Hashtag in path name or file name causing error
Summary: Hashtag in path name or file name causing error
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.1.3.1 rc
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2016-05-09 09:54 UTC by Andreas
Modified: 2016-05-10 12:09 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas 2016-05-09 09:54:50 UTC
Hello,

below there's a short macro that creates a TXT file with a bit of content.
If you use path names that contain a hashtag either in the path or in the file name, you will find the macro fail and produce an error message:
"BASIC-Laufzeitfehler. [= german for: Basic runtime error]
 Es ist eine Ausnahme aufgetreten [= german for: An exception has occured]
 Type: com.sun.star.ucb.ContentCreationException
 Message: Unable to create Content for <file:///D:/#/Test.txt>: ."
Using an URL without any hashtag, the macro will work fine.

I have found this error in LibO 5.1.3.2 but not in LibO 5.0.5.

Sub Main
    Dim oFileAccess, oFileOutput, sFileUrl As String, sText As String
    sText = "This is a piece oft text."
    sFileUrl = "file:///D:/#/Test.txt"   '=> error message.
    'sFileUrl = "file:///D:/#a/Test.txt"    '=> error message.
    'sFileUrl = "file:///D:/a/#Test.txt"    '=> error message.
    'sFileUrl = "file:///D:/a/Test.txt"     '=> No error message.
    oFileAccess = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
    oFileOutput = CreateUnoService("com.sun.star.io.TextOutputStream")
    oFileOutput.SetOutputStream(oFileAccess.OpenFileWrite(sFileUrl))
    oFileOutput.WriteString(sText & Chr(13) & Chr(10))
    oFileOutput.CloseOutput()
    Print "Done"
End Sub
Comment 1 raal 2016-05-10 11:14:29 UTC
This seems to have begun at the below commit.
Adding Cc: to Stephan Bergmann ; Could you possibly take a look at this one? Thanks
 5e8294b0ca5f96b0d65ba416a20547e15d14f38e is the first bad commit
commit 5e8294b0ca5f96b0d65ba416a20547e15d14f38e
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Wed Nov 4 12:30:39 2015 -0800

    source d3248d1fd83cca67a11dd593c124694382bf5f34

author	Stephan Bergmann <sbergman@redhat.com>	2015-11-04 07:39:35 (GMT)
committer	Stephan Bergmann <sbergman@redhat.com>	2015-11-04 09:19:59 (GMT)
commit d3248d1fd83cca67a11dd593c124694382bf5f34 (patch)
tree 22abbb7e2cb96222d6bead9db0fda86b39589508
parent e8a5e8023d8c3adcd0d91160a82f093e76b85030 (diff)
Handle URLs with query or fragment (or containing NUL chars)
Comment 2 Stephan Bergmann 2016-05-10 12:09:13 UTC
"#" has special meaning in URLs.  If you want a pathname containing "#" represented as a file URL, you need to escape it as "%23".