Description: In libreoffice < 7, the python API "storeAsURL" work. In libreoffice >= 7, the python API "storeAsURL" hang and crash with the code: __main__.ErrorCodeIOException: SfxBaseModel::impl_store <file:///home/user/libreoffice_bug/docx.docx.nopassword> failed: 0x20d(Error Area:Io Class:General Code:13) /build/libreoffice-fresh/src/libreoffice-7.0.2.2/sfx2/source/doc/sfxbasemodel.cxx:3153 I will attach all the files required to reproduce this issue easily. (I am fairly new with libreoffice, tried to find any announcement for breaking change between <7 and >=7, but found nothing relevant.) Steps to Reproduce: 1. python3 ./remove_password.py /{ABSOLUTE_PATH}/docx.docx '' Actual Results: In libreoffice <7: A file is correctly created In libreoffice >=7: Hang or crash Expected Results: A file should be created Reproducible: Always User Profile Reset: No Additional Info: Non working environment: LibreOffice 7.0.2.2 00(Build:2), archlinux Working environment: LibreOffice 6.4.7.2 40(Build:2), fedora 32
Created attachment 166919 [details] test file
Created attachment 166920 [details] script
To make it easier to debug I only attached 1 test file ("docx.docx"), this document is NOT protected by a password. But the issue is also producible with password protected file
I searched a bit deeper and found 2 regression between 6.4.X and 7.X. This ticket will be for only one of those, I will open a new ticket for other. Commit 0de0b1b64a1c122254bb821ea0eb9b038875e8d4 ( https://gerrit.libreoffice.org/c/core/+/104345 / https://github.com/LibreOffice/core/commit/0de0b1b64a1c122254bb821ea0eb9b038875e8d4 ) From what I understand (never wrote nor read any meaningful C++ nor looked in the libreoffice codebase before). Before this commit: it checked if a password have been submit, if that is the case, then do something. After this commit: it check if the document contains encrypted data, if that is the case, then do something. This change of behavior broke at least 1 use case: Trying to open a non encrypted file using the API/uno while submitting a password. I tried to rewrote this part to fix this use-case: ``` // Also, ( maybe the new itemset contains new values, otherwise they will be empty ) bool bPasswordProtected = true; if (xMergedParams->HasItem(SID_ENCRYPTIONDATA)) { const SfxUnoAnyItem* pEncryptionDataItem = xMergedParams->GetItem<SfxUnoAnyItem>(SID_ENCRYPTIONDATA, false); if (pEncryptionDataItem) { uno::Sequence<beans::NamedValue> aEncryptionData; pEncryptionDataItem->GetValue() >>= aEncryptionData; for (const auto& rItem : std::as_const(aEncryptionData)) { if (rItem.Name == "CryptoType") { OUString aValue; rItem.Value >>= aValue; if (aValue != "StrongEncryptionDataSpace") { // This is not just a password protected document. Let's keep encryption data as is. bPasswordProtected = false; } break; } } } }else if (xMergedParams->HasItem( SID_PASSWORD )){ bPasswordProtected = true; } if (bPasswordProtected){ // For password protected documents remove encryption data during "Save as..." xMergedParams->ClearItem(SID_PASSWORD); xMergedParams->ClearItem(SID_ENCRYPTIONDATA); } ``` (Basically, adding 1 "else if", and moving a block. Didn't sent a proper pull request yet, probably later this week) I recompiled and I confirm that with this modification it work for my usecase. Between my previous comments and now I updated my test script and input file, I will attach the new versions in this ticket. The new command is ``` ./remove_password.py /home/user/qubes-app-linux-pdf-converter/tests/files_success/csv.tmp '' ``` ("csv.tmp" is a standard csv file) With the patch, the output is ``` libreoffice process wait for socket :file:///home/user/qubes-app-linux-pdf-converter/tests/files_success/csv.tmp: ``` , the process terminate within seconds and the file is correctly created. Without the patch, the output is ``` libreoffice process wait for socket :file:///home/user/qubes-app-linux-pdf-converter/tests/files_success/csv.tmp: ``` , the process does not terminate (hang indefinitly), and when I send a "CTRL+C" it display the following error "__main__.ErrorCodeIOException: SfxBaseModel::impl_store <file:///home/user/qubes-app-linux-pdf-converter/tests/files_success/csv.tmp.nopassword> failed: 0x20d(Error Area:Io Class:General Code:13) /home/user/core/sfx2/source/doc/sfxbasemodel.cxx:3153 "
Created attachment 170499 [details] script I used to test the regression
Created attachment 170500 [details] test file
Created attachment 170502 [details] patch example Patch applied on my side, that apparently fix the issue. I compiled libreoffice and tested it worked as expected with my script. Nothing more.
Xisco, could you please look at this problem, the script and at the patch too. Thank you
(In reply to libreoffice from comment #4) > I tried to rewrote this part to fix this use-case: > > ``` > // Also, ( maybe the new itemset contains new values, otherwise they will be > empty ) > bool bPasswordProtected = true; > > if (xMergedParams->HasItem(SID_ENCRYPTIONDATA)) > { > const SfxUnoAnyItem* pEncryptionDataItem > = xMergedParams->GetItem<SfxUnoAnyItem>(SID_ENCRYPTIONDATA, > false); > if (pEncryptionDataItem) > { > uno::Sequence<beans::NamedValue> aEncryptionData; > pEncryptionDataItem->GetValue() >>= aEncryptionData; > for (const auto& rItem : std::as_const(aEncryptionData)) > { > if (rItem.Name == "CryptoType") > { > OUString aValue; > rItem.Value >>= aValue; > if (aValue != "StrongEncryptionDataSpace") > { > // This is not just a password protected document. > Let's keep encryption data as is. > bPasswordProtected = false; > } > break; > } > } > } > }else if (xMergedParams->HasItem( SID_PASSWORD )){ > bPasswordProtected = true; > } > if (bPasswordProtected){ > // For password protected documents remove encryption data during > "Save as..." > xMergedParams->ClearItem(SID_PASSWORD); > xMergedParams->ClearItem(SID_ENCRYPTIONDATA); > } > ``` The first: bool bPasswordProtected = true; in your patch makes your 'else if' redundant, so is surely not what you intended.
It hangs for me as well and I tested with linux-64-7.0 bibisect repo and confirm the finding.