Bug 107968 - Multiple slash handling in Unix directory code wrong
Summary: Multiple slash handling in Unix directory code wrong
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Chris Sherlock
URL:
Whiteboard: target:5.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-20 07:51 UTC by Chris Sherlock
Modified: 2017-05-21 11:09 UTC (History)
1 user (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 Chris Sherlock 2017-05-20 07:51:56 UTC
It appears that in the OSL code that we do some sanity checking for Unix system paths and converts double slashes (//) to a single slash. This is actually correct behaviour (except for beginning with double slashes - see bug 107967), but we haven't quite got this behaviour correct. 

POSIX actually doesn't mandate double-slashes be replaced by a single slash, it actually states that multiple slashes should be replaced with a single slash when parsing a system directory. We currently only check if there is a double-slash, which means that /path//to/file.txt becomes /path/to/file.txt but /path////to/file.txt becomes /path//to/file.txt

This shouldn't cause too many issues, however it causes us to also make ////path/to/file.txt to change to //path/to/file.txt instead of /path/to/file.txt - and that *is* wrong and problematic behaviour because POSIX treats a leading double-slash specially.
Comment 1 Chris Sherlock 2017-05-20 08:16:07 UTC
It appears that the code comments are the issue here, they talk about double-slashes but actually, the code correctly checks for multiple slashes and changes to a single slash. 

I will add a unit test to check for this, and I've updated the comments.
Comment 2 Commit Notification 2017-05-20 11:11:54 UTC
Chris Sherlock committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0a72b799718a17b0ea49dc36d974da28000fc952

tdf#107968 - double slash handling misleading; add unit test

It will be available in 5.4.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 3 Xisco Faulí 2017-05-20 11:26:06 UTC
Since there's a commit for this bug, moving it to NEW...
Comment 4 Chris Sherlock 2017-05-21 11:09:51 UTC
The commit fixed the issue.