diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2021-09-01 15:47:40 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-09-16 15:54:57 +0200 |
commit | 40f38fd16dad4374543d4a7a109b3264837ce8d1 (patch) | |
tree | e7d7691f45b9fb0edade4ce6c3bca6739cbed43d /sc | |
parent | 522905a0674992fe2ab52afc1415c46ad33cf7f0 (diff) |
tdf#115933 XLSX import: fix permission for editing
The passwords for editing in XLSX documents
created with Excel weren't asked and verified.
Note: LibreOffice supports only a subset of the hashing
algorithms specified in MS-OE376, according to
DocPasswordHelper::GetOoxHashAsVector() and
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oe376/f70a4140-340b-4e94-a604-dff25b9846b1.
Also the documents encrypted with unsupported algorithms
got edit protection now, but it's not possible to add
permission to edit them (copy of these documents are still
editable).
Change-Id: Iabc90f6bba4ed071dd2c60e9dea905481816964b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121497
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/uitest/calc_tests9/tdf115933.py | 32 | ||||
-rw-r--r-- | sc/qa/uitest/data/tdf115933.xlsx | bin | 0 -> 9291 bytes | |||
-rw-r--r-- | sc/source/filter/oox/workbooksettings.cxx | 15 |
3 files changed, 47 insertions, 0 deletions
diff --git a/sc/qa/uitest/calc_tests9/tdf115933.py b/sc/qa/uitest/calc_tests9/tdf115933.py new file mode 100644 index 000000000000..be7719487958 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf115933.py @@ -0,0 +1,32 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 115933 - XLSX <fileSharing> password protected with algorithmName, hashValue, saltValue and spinCount + +class tdf115933(UITestCase): + + def test_tdf115933(self): + with self.ui_test.load_file(get_url_for_data_file("tdf115933.xlsx")): + #The document was created in Excel. + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + document = self.ui_test.get_component() + + self.assertTrue(document.isReadonly()) + + #Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+SHIFT+M"})) as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/tdf115933.xlsx b/sc/qa/uitest/data/tdf115933.xlsx Binary files differnew file mode 100644 index 000000000000..a6073a76e506 --- /dev/null +++ b/sc/qa/uitest/data/tdf115933.xlsx diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx index a7ab887bf967..ae2aa82e1a31 100644 --- a/sc/source/filter/oox/workbooksettings.cxx +++ b/sc/source/filter/oox/workbooksettings.cxx @@ -210,6 +210,21 @@ void WorkbookSettings::finalizeImport() if (maFileSharing.mbRecommendReadOnly || !maFileSharing.maHashValue.isEmpty()) aSettingsProp.setProperty( PROP_LoadReadonly, true ); + if (!maFileSharing.maHashValue.isEmpty()) + { + Sequence<PropertyValue> aResult; + aResult.realloc(4); + aResult[0].Name = "algorithm-name"; + aResult[0].Value <<= maFileSharing.maAlgorithmName; + aResult[1].Name = "salt"; + aResult[1].Value <<= maFileSharing.maSaltValue; + aResult[2].Name = "iteration-count"; + aResult[2].Value <<= maFileSharing.mnSpinCount; + aResult[3].Name = "hash"; + aResult[3].Value <<= maFileSharing.maHashValue; + aSettingsProp.setProperty(PROP_ModifyPasswordInfo, aResult); + } + if( maFileSharing.mnPasswordHash != 0 ) aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) ); } |