Compare commits

..

15 Commits

Author SHA1 Message Date
be5627ba60 Merge branch hotfix/v8.3.2 into hotfix/v8.3.3 2025-04-01 08:34:21 +00:00
a0c49966b9 Merge pull request 'fix bug #73582' (#264) from fix/bug73582 into hotfix/v8.3.3
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/264
2025-03-24 10:11:00 +00:00
58f4828563 Merge pull request 'fix bug #73587' (#263) from fix/bug73587 into hotfix/v8.3.3
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/263
2025-03-24 10:09:10 +00:00
96a7e3ac36 Fix bug 73514 2025-03-24 09:05:21 +03:00
d257c68d5f Merge branch hotfix/v8.3.2 into master 2025-03-19 12:45:29 +00:00
9390761867 fix bug #73587 2025-03-19 13:10:50 +06:00
e100f594d7 fix bug #73582 2025-03-18 18:12:52 +03:00
1181cb222d Fix memory bug 2025-03-18 13:15:55 +03:00
c4bcf11d91 Merge pull request 'Fix docbuilder from archives' (#259) from fix/docbuilder-register into hotfix/v8.3.2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/259
2025-03-17 12:14:54 +00:00
72ee82211d Add note 2025-03-17 15:36:03 +04:00
2ab94263f2 Remove lib directory 2025-03-17 15:29:49 +04:00
410e8100fe Merge pull request 'Fix bug #73467' (#257) from fix/bug73467 into hotfix/v8.3.2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/257
2025-03-17 07:19:06 +00:00
3e3ac51f56 Merge pull request 'Fix bug #73483' (#258) from fix/bug-73483 into hotfix/v8.3.2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/258
2025-03-15 19:40:35 +00:00
4f4f61bb19 Fix bug #73483 2025-03-15 01:04:27 +03:00
6fe0f2828e Fix bug #73467 2025-03-14 21:53:47 +06:00
10 changed files with 260 additions and 72 deletions

View File

@ -1159,58 +1159,222 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
}
return false;
}
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
struct TIWAField
{
size_t m_unStart;
size_t m_unEnd;
unsigned m_uIndex;
unsigned m_unWireType;
uint64_t m_oValue;
};
bool ReadUVar(BYTE* pBuffer, size_t unEndPos, size_t& unPos, uint64_t& unValue)
{
std::vector<unsigned char> arBytes;
arBytes.reserve(8);
unValue = 0;
bool bNext = true;
while (unPos < unEndPos && bNext)
{
const unsigned char c = pBuffer[unPos++];
arBytes.push_back((unsigned char)(c & ~0x80));
bNext = c & 0x80;
}
if (bNext && unPos == unEndPos)
return false;
for (std::vector<unsigned char>::const_reverse_iterator it = arBytes.rbegin(); it != arBytes.rend(); ++it)
{
if (std::numeric_limits<uint64_t>::max() >> 7 < unValue ||
std::numeric_limits<uint64_t>::max() - (unValue << 7) < *it) // overflow
return false;
unValue = (unValue << 7) + *it;
}
return true;
}
bool ReadIWAField(BYTE* pBuffer, size_t unEndPos, size_t& unPos, TIWAField& oIWAField)
{
if (NULL == pBuffer || unPos + 2 > unEndPos)
return false;
unsigned uSpec;
uSpec = (unsigned)pBuffer[unPos++];
oIWAField.m_unWireType = uSpec & 0x7;
oIWAField.m_unStart = unPos;
switch (oIWAField.m_unWireType)
{
case 0:
{
if (!ReadUVar(pBuffer, unEndPos, unPos, oIWAField.m_oValue))
return false;
break;
}
case 1:
{
unPos += 4;
break;
}
case 2:
{
uint64_t unLen;
if (!ReadUVar(pBuffer, unEndPos, unPos, unLen) || unPos + unLen > unEndPos)
return false;
oIWAField.m_unStart = unPos;
unPos += unLen;
break;
}
case 5:
{
unPos += 2;
break;
}
default:
return false;
}
oIWAField.m_unEnd = unPos;
oIWAField.m_uIndex = uSpec >> 3;
return true;
}
bool DetectIWorkFormat(const std::wstring& fileName, int &nType)
{
COfficeUtils OfficeUtils(NULL);
ULONG nBufferSize = 0;
ULONG unSize = 0;
BYTE* pBuffer = NULL;
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, unSize);
if (hresult != S_OK || NULL == pBuffer)
return false;
#define CLEAR_BUFFER_AND_RETURN(return_value)\
do{\
delete[] pBuffer;\
return return_value;\
}while(false)
if (unSize < 13)
CLEAR_BUFFER_AND_RETURN(false);
size_t uPos = 6;
for (; uPos < 12; ++uPos)
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
delete[] pBuffer;
pBuffer = NULL;
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
if (0x08 == pBuffer[uPos] && 0x01 == pBuffer[uPos + 1])
{
delete[] pBuffer;
pBuffer = NULL;
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
return true;
--uPos;
break;
}
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
{
delete[] pBuffer;
pBuffer = NULL;
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
return true;
}
std::wstring::size_type nExtPos = fileName.rfind(L'.');
std::wstring sExt = L"unknown";
if (nExtPos != std::wstring::npos)
sExt = fileName.substr(nExtPos);
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
if (0 == sExt.compare(L".pages"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
else if (0 == sExt.compare(L".numbers"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
else if (0 == sExt.compare(L".key"))
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
return true;
}
return false;
if (12 == uPos)
CLEAR_BUFFER_AND_RETURN(false);
uint64_t unHeaderLen;
if (!ReadUVar(pBuffer, unSize, uPos, unHeaderLen))
CLEAR_BUFFER_AND_RETURN(false);
const size_t uStartPos = uPos;
if (unHeaderLen < 8 || unSize < unHeaderLen + uStartPos)
CLEAR_BUFFER_AND_RETURN(false);
uPos += 2;
TIWAField oMessageField;
if (!ReadIWAField(pBuffer, uStartPos + unHeaderLen, uPos, oMessageField) || 2 != oMessageField.m_unWireType ||
2 != oMessageField.m_uIndex)
CLEAR_BUFFER_AND_RETURN(false);
size_t uSubPos = oMessageField.m_unStart;
TIWAField oField;
if (!ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oField) || 0 != oField.m_unWireType ||
1 != oField.m_uIndex)
CLEAR_BUFFER_AND_RETURN(false);
switch (oField.m_oValue)
{
case 1:
{
uint32_t unDataLen = 0;
TIWAField oTempField;
if (ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) &&
ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) && 0 == oTempField.m_unWireType &&
3 == oTempField.m_uIndex)
unDataLen += oTempField.m_oValue;
size_t unTempPos = uStartPos + unHeaderLen;
// keynote: presentation ref in 2
// number: sheet ref in 1
if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
(2 != oTempField.m_unWireType || 1 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
{
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
CLEAR_BUFFER_AND_RETURN(true);
}
else if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
(2 != oTempField.m_unWireType || 2 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
{
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
CLEAR_BUFFER_AND_RETURN(true);
}
break;
}
case 10000:
{
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
CLEAR_BUFFER_AND_RETURN(true);
}
}
CLEAR_BUFFER_AND_RETURN(false);
}
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
{
if (DetectIWorkFormat(fileName, nFileType))
return true;
std::wstring::size_type nExtPos = fileName.rfind(L'.');
std::wstring sExt = L"unknown";
if (nExtPos != std::wstring::npos)
sExt = fileName.substr(nExtPos);
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
if (0 == sExt.compare(L".pages"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
else if (0 == sExt.compare(L".numbers"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
else if (0 == sExt.compare(L".key"))
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
else
return false;
return true;
}
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
{
documentID.clear();

View File

@ -609,14 +609,15 @@ class FileTypes:
PNG = _IMAGE_MASK + 0x0005
BMP = _IMAGE_MASK + 0x0008
builder_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')
# NOTE: do not change builder_path manually!
builder_path = os.path.dirname(os.path.realpath(__file__))
_loadLibrary(builder_path)
CDocBuilder.Initialize(builder_path)
def registerLibrary(license_path):
docbuilder_bin = os.path.dirname(os.path.realpath(__file__)) + "/lib/docbuilder"
docbuilder_bin = os.path.join(builder_path, "docbuilder")
if ("windows" == platform.system().lower()):
docbuilder_bin += ".exe"
return subprocess.call([docbuilder_bin, "-register", license_path], stderr=subprocess.STDOUT, shell=True)
return subprocess.call([docbuilder_bin, "-register", license_path], stderr=subprocess.STDOUT, shell=True)
atexit.register(CDocBuilder.Dispose)

View File

@ -165,9 +165,14 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
JSSmart<CJSObject> pNativeObject = Native->toObject();
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
if (m_pInternal->m_pAppImage)
if (m_pInternal->m_pAppImage && pNativeEmbedObject)
{
delete m_pInternal->m_pAppImage;
m_pInternal->m_pAppImage = new CGraphicsAppImage();
m_pInternal->m_pAppImage = NULL;
}
if (NULL == m_pInternal->m_pAppImage)
m_pInternal->m_pAppImage = new CGraphicsAppImage();
if (pNativeEmbedObject)
{

View File

@ -238,7 +238,8 @@ namespace BinXlsxRW
ExternalLinksAutoRefresh = 26,
TimelineCaches = 27,
TimelineCache = 28,
Metadata = 29
Metadata = 29,
PivotCachesTmp = 107
};}
namespace c_oSerWorkbookProtection {enum c_oSerWorkbookProtection{
AlgorithmName = 0,
@ -456,6 +457,8 @@ namespace BinXlsxRW
TimelinesList = 48,
Timelines = 49,
Timeline = 50,
PivotTableTmp = 126,
};}
namespace c_oSerWorksheetProtection {enum c_oSerWorksheetPropTypes

View File

@ -2152,7 +2152,7 @@ void BinaryWorkbookTableWriter::WriteWorkbook(OOX::Spreadsheet::CWorkbook& workb
}
if (workbook.m_oPivotCaches.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::PivotCaches);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::PivotCachesTmp);
WritePivotCaches(workbook, workbook.m_oPivotCaches.get());
if (workbook.m_oExtLst.IsInit())
{
@ -4772,7 +4772,7 @@ void BinaryWorksheetTableWriter::WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet
if ((pPivotTableFile) && (pPivotTableFile->m_oPivotTableDefinition.IsInit()))
{
BinaryTableWriter oBinaryTableWriter(m_oBcw.m_oStream);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::PivotTable);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::PivotTableTmp);
if(pPivotTableFile->m_oPivotTableDefinition->m_oCacheId.IsInit())
{
auto cachePos = m_oBcw.WriteItemStart(c_oSer_PivotTypes::cacheId);

View File

@ -2189,7 +2189,8 @@ int BinaryWorkbookTableReader::ReadWorkbookTableContent(BYTE type, long length,
m_oWorkbook.m_oExternalReferences.Init();
READ1_DEF(length, res, this->ReadExternalReferences, poResult);
}
else if (c_oSerWorkbookTypes::PivotCaches == type)
else if (c_oSerWorkbookTypes::PivotCaches == type ||
c_oSerWorkbookTypes::PivotCachesTmp == type)
{
m_oWorkbook.m_oPivotCachesXml.Init();
m_oWorkbook.m_oPivotCachesXml->append(L"<pivotCaches>");
@ -4621,7 +4622,25 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
RELEASEOBJECT(oPivotCachesTemp.pTable);
}
SEEK_TO_POS_END2();
//-------------------------------------------------------------------------------------------------------------
//tmp-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::PivotTableTmp);
PivotCachesTemp oPivotCachesTemp;
READ1_DEF(length, res, this->ReadPivotTable, &oPivotCachesTemp);
boost::unordered_map<long, NSCommon::smart_ptr<OOX::File>>::const_iterator pair = m_mapPivotCacheDefinitions.find(oPivotCachesTemp.nCacheId);
if (m_mapPivotCacheDefinitions.end() != pair && NULL != oPivotCachesTemp.pTable)
{
NSCommon::smart_ptr<OOX::File> pFileTable(oPivotCachesTemp.pTable);
oPivotCachesTemp.pTable->AddNoWrite(pair->second, L"../pivotCache");
m_pCurWorksheet->Add(pFileTable);
}
else
{
RELEASEOBJECT(oPivotCachesTemp.pTable);
}
SEEK_TO_POS_END2();
//tmp-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::NamedSheetView);
smart_ptr<OOX::Spreadsheet::CNamedSheetViewFile> pNamedSheetViewFile(new OOX::Spreadsheet::CNamedSheetViewFile(NULL));
pNamedSheetViewFile->m_oNamedSheetViews.Init();

View File

@ -589,7 +589,7 @@ namespace SimpleTypes
this->m_eValue = underlineDouble;
else if(L"doubleAccounting" == sValue)
this->m_eValue = underlineDoubleAccounting;
else if(L"none" == sValue)
else if(L"none" == sValue || L"0" == sValue)
this->m_eValue = underlineNone;
else if(L"single" == sValue)
this->m_eValue = underlineSingle;

View File

@ -1158,7 +1158,7 @@ namespace OOX
ColumnRef = static_cast<XLS::PtgExtraCol*>(BinFmla.rgcb.getPtgs().back().get())->col;
if(!SharedFormulasRef::sharedRefsLocations)
SharedFormulasRef::sharedRefsLocations = std::unique_ptr<std::map<_UINT32, XLS::CellRef>>(new std::map<_UINT32, XLS::CellRef>);
m_oSi = (unsigned int)SharedFormulasRef::sharedRefsLocations->size() - 1;
m_oSi = (unsigned int)SharedFormulasRef::sharedRefsLocations->size();
SharedFormulasRef::sharedRefsLocations->emplace(m_oSi->GetValue(), XLS::CellRef(rowRef, ColumnRef, true, true));
}
@ -4369,7 +4369,7 @@ namespace OOX
}
bool CRow::compressCell(CCell* pCell)
{
if(!pCell->m_oValue.IsInit() && !m_arrItems.empty())
if(!pCell->m_oValue.IsInit() && !pCell->m_oFormula.IsInit() && !m_arrItems.empty())
{
auto prevCell = m_arrItems.back();
if(!prevCell->m_oRepeated.IsInit())

View File

@ -40,7 +40,7 @@
#include "../../XlsbFormat/Biff12_records/BeginHeaderFooter.h"
#include "../../XlsbFormat/Biff12_records/SheetProtectionIso.h"
#include "../../XlsbFormat/Biff12_records/SheetProtection.h"
#include "../../XlsbFormat/Biff12_records/LegacyDrawingHF.h"
#include "../../XlsbFormat/Biff12_records/LegacyDrawingHF.h"
#include "../../XlsbFormat/Biff12_records/Margins.h"
#include "../../XlsbFormat/Biff12_records/PrintOptions.h"
#include "../../XlsbFormat/Biff12_records/WsProp.h"
@ -3632,7 +3632,7 @@ namespace OOX
void CSheetProtection::toBin(XLS::StreamCacheWriterPtr& writer)
{
XLS::CFRecordPtr record;
unsigned char *flagBuf;
unsigned char *flagBuf = NULL;
if(m_oSpinCount.IsInit() || m_oHashValue.IsInit() || m_oSaltValue.IsInit())
{
record = writer->getNextRecord(XLSB::rt_SheetProtectionIso);

View File

@ -181,33 +181,29 @@ namespace NSX2T
char** penv;
#ifndef _MAC
char* nenv[2];
nenv[0] = &sLibraryDir[0];
nenv[1] = NULL;
penv = nenv;
if(bIsSaveEnvironment)
{
putenv(&sLibraryDir[0]);
penv = environ;
}
else
{
char* nenv[2];
nenv[0] = &sLibraryDir[0];
nenv[1] = NULL;
penv = nenv;
}
#else
char* nenv[3];
nenv[0] = &sLibraryDir[0];
nenv[1] = &sPATH[0];
nenv[2] = NULL;
penv = nenv;
if(bIsSaveEnvironment)
{
putenv(&sLibraryDir[0]);
putenv(&sPATH[0]);
penv = environ;
}
else
{
char* nenv[3];
nenv[0] = &sLibraryDir[0];
nenv[1] = &sPATH[0];
nenv[2] = NULL;
penv = nenv;
}
#endif
execve(sProgramm.c_str(),
(char * const *)nargs,