Bug 131693 - Unable to open document if path has "\\?\" UNC prefix in Windows
Summary: Unable to open document if path has "\\?\" UNC prefix in Windows
Status: RESOLVED DUPLICATE of bug 157820
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.4.2.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-30 06:49 UTC by Tomas
Modified: 2024-12-09 16:14 UTC (History)
6 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 Tomas 2020-03-30 06:49:53 UTC
Description:
If the path to the document exceeds MAX_PATH, Windows adds "\\?\" UNC prefix to the path. However, LibreOffice evaluates it as invalid path and crashes. If I remove the prefix, the document can be opened even if path is much longer than MAX_PATH.

Steps to Reproduce:
1. Enable long path support in Win 10
2. Double click document, that is saved at path longer than 260 chars


Actual Results:
Splash screen of LibreOffice appears and shuts down after a while.

Expected Results:
Should open the document.


Reproducible: Always


User Profile Reset: No



Additional Info:
When opening over Open dialog in LibreOffice, everything works fine. Even directly called with path without "\\?\" prefix, the document opens.
Comment 1 Buovjaga 2020-09-04 14:37:11 UTC
The problem seems to be broader, affecting UNC prefix as a whole: bug 91851. Do you agree?
Comment 2 Mike Kaganski 2020-11-30 11:14:48 UTC
(In reply to Buovjaga from comment #1)
No. The problem here is specifically with "\\?\" prefix, not handled in INetURLObject::convertRelToAbs and INetURLObject::setAbsURIRef, both used from GetURL_Impl in desktop/source/app/app.cxx.

This results in the URL like "file:////?/C:/...", which then is converted back to system path in osl_getSystemPathFromFileURL_ (sal/osl/w32/file_url.cxx), which strips "file:///", and the rest "/?/C:/..." is not a valid path.

This can be easily fixed by a modification of osl_getSystemPathFromFileURL_ to test for starting with "file:////?/" and then skipping only 7 characters, but it seems that the proper fix is in INetURLObject, which should in theory behave just like osl_getFileURLFromSystemPath for such paths, simply dropping "\\?\" from the result URL.

However, I hesitate to touch this code myself (too fragile); Stephan, could you take a look at it please?
Comment 3 QA Administrators 2023-06-30 03:13:29 UTC Comment hidden (obsolete)
Comment 4 PICCORO Lenz McKAY 2024-12-05 21:14:12 UTC
hi, what is the status of this bug?

i am a free software supporter and a bunch of people will use libreoffice again if this is already or will be fixed! Recently company changed to offcie360 and foundf this limitation inside the standar alone product and i want to get the oportunity to cvhange again the product becouse they used somuch long paths over net drives...

thanks in advance
Comment 5 PICCORO Lenz McKAY 2024-12-05 21:23:50 UTC
Some usefully information:

Here the official M$ information about the current office products limitation and if libreoffice surpassed such limitation it will have a feature that other products cannot do..

https://learn.microsoft.com/en-us/answers/questions/1573115/how-to-allow-excel-365-to-open-file-paths-is-longe

...according to this 
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

NTFS is not the problem. NTFS max path length is 32,000+ characters. It’s a stupid limitation in Guindows Office API and certain other parts of windows. File chooser dialogs and the like. Changing the longpathsenabled registry key to 1 will not help! 

in the previous comment https://bugs.documentfoundation.org/show_bug.cgi?id=131693#c2 it pointed that solution it seems easyle.. but over years we dont know if the code was touch or not? cos those bugzilla issues are not property linked to source code or commit as any other git tool like forgetto or gitlab does..

Recently company changed to offcie360 and found this limitation inside the standard alone product and this is a great oportunity to change again the product because many people still used so much long paths over net drives.. please dont waste this time oportunity

Thanks again in advance
Comment 6 Mike Kaganski 2024-12-08 11:38:21 UTC
(In reply to PICCORO Lenz McKAY from comment #4)
> hi, what is the status of this bug?

It was fixed in bug 157820 for 7.6.3

*** This bug has been marked as a duplicate of bug 157820 ***
Comment 7 Mike Kaganski 2024-12-08 11:41:36 UTC
(In reply to PICCORO Lenz McKAY from comment #5)

And note, that LibreOffice doesn't need that \\?\ prefix to handle long paths. If there is a problem accessing long paths, it must be filed as a separate bug. This one was about something different: the failure to handle even short path starting with \\?\.
Comment 8 PICCORO Lenz McKAY 2024-12-09 16:14:13 UTC
(In reply to Mike Kaganski from comment #7)
> (In reply to PICCORO Lenz McKAY from comment #5)
> 
> And note, that LibreOffice doesn't need that \\?\ prefix to handle long

as Tomas said https://bugs.documentfoundation.org/show_bug.cgi?id=131693#c0

this \\?\. is parsed by windows 10.. so i cannot control that!

> paths. If there is a problem accessing long paths, it must be filed as a
> separate bug. This one was about something different: the failure to handle
> even short path starting with \\?\.


noted the quote:

> Windows adds "\\?\" UNC prefix to the path. However, LibreOffice evaluates it as invalid path and crashes. If I remove the prefix, the document can be opened even if path is much longer than MAX_PATH.

this bug is about "\\?\" then i will try again and post later.. but i repeat, the "\\?\" is auytomatically add by windows api