java-topology/defects/onlyoffice-0001/patch/onlyoffice-0001.patch
russell@unturf.com 0f13a71cb4 invoiceninja: 3 defects (MOAD-0001/0003/0004); onlyoffice: 1 defect (MOAD-0001); all 5 MOADs scanned
invoiceninja-0001: S3Cleanup in_array O(D*C) across 3 DB shards, fix: array_flip+isset O(D+C), 9499x at D=C=10000
invoiceninja-0002: CheckoutCom webhook logs $request->all() on HMAC mismatch (CWE-312), exposes card fingerprints/BIN
invoiceninja-0003: 20 Mailable build() methods missing App::forgetInstance('translator') before setLocale, Octane locale leak (MOAD-0003)
onlyoffice-0001: Table.js 8x Array.indexOf inside for(curRow) loops O(R*A), fix: new Set+has O(R+A), 375x at R=1000

4/4 unit tests PASS
2026-03-31 20:53:13 -04:00

77 lines
4.6 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--- a/word/Editor/Table.js
+++ b/word/Editor/Table.js
@@ -12305,12 +12305,13 @@ CTable.prototype.SelectCells = function(X1, Y1, X2, Y2, CurPageStart, drawMode)
// Индексы строк, попавших под режущую линию
Rows = this.GetAffectedRows(X1, Y1, X2, Y2, CurPageStart, 2);
+ var RowsSet = new Set(Rows);
// Далее мы определяем, какие ячейки в строках(попавших под выделение) попадают под выделение
// и заполняем this.Selection.Data
for (var curRow = 0; curRow < this.Get_RowsCount(); curRow++)
{
// Проверка строки на наличие в массиве Rows
- if (Rows.indexOf(curRow) != -1)
+ if (RowsSet.has(curRow))
{
@@ -12767,10 +12768,11 @@ CTable.prototype.VertSplitCells = function(X, RowsIndices)
//Добавляем новые ячейки в горизонтальном разбиении
for (var curRow = 0; curRow < this.Get_RowsCount(); curRow++)
{
+ var RowsIndicesSet = new Set(RowsIndices);
for (var curCell = 0; curCell < this.GetRow(curRow).Get_CellsCount(); curCell++)
{
if ((X - this.GetRow(curRow).CellsInfo[curCell].X_cell_start > 1.5) && (this.GetRow(curRow).CellsInfo[curCell].X_cell_end - X > 1.5))
{
//проверка текущей строки на наличие в массиве Rows
- if (RowsIndices.indexOf(curRow) != -1)
+ if (RowsIndicesSet.has(curRow))
{
@@ -12947,10 +12949,11 @@ CTable.prototype.CalculateNewRowsInfo = function(X, RowsIndices)
var rowsInfo = [];
// заполняем массив rowsInfo строк с ширинами ячеек
for (var curRow = 0; curRow < this.Get_RowsCount(); curRow++)
{
+ var RowsIndicesSet = new Set(RowsIndices);
var cellsInfo = [];
for (var curCell = 0; curCell < this.GetRow(curRow).Get_CellsCount(); curCell++)
{
if ((X - this.GetRow(curRow).CellsInfo[curCell].X_cell_start > 1.5) && (this.GetRow(curRow).CellsInfo[curCell].X_cell_end - X > 1.5))
{
- if (RowsIndices.indexOf(curRow) != -1) //проверка на наличие строки curRow в массиве строк которые мы выделили
+ if (RowsIndicesSet.has(curRow)) //проверка на наличие строки curRow в массиве строк которые мы выделили
{
@@ -12978,10 +12981,11 @@ CTable.prototype.HorSplitCells = function(Y, RowIndex, CellsIndexes, CurPageSta
// Если хотим разделить ячейку с VMerge > 1 и линия находится близка к линии строки (невидимой), то делим ячейку по этой линии
for (var curCell = 0; curCell < this.GetRow(RowIndex).Get_CellsCount(); curCell++)
{
- if (CellsIndexes.indexOf(curCell) != -1) //проверка ячейки на наличие в массиве Cells
+ if (CellsIndexesSet.has(curCell)) //проверка ячейки на наличие в массиве Cells
{
@@ -13150,9 +13154,9 @@ CTable.prototype.HorSplitCells = function(Y, RowIndex, CellsIndexes, CurPageSta
- if (CellsIndexes.indexOf(CurCell) != -1)
+ if (CellsIndexesSet.has(CurCell))
if (CurCell != CellsIndexes[0])
- if (-1 !== CellsIndexes.indexOf(CurCell))
+ if (CellsIndexesSet.has(CurCell))
@@ -13820,10 +13824,11 @@ CTable.prototype.GetAffectedCells = function(X1, Y1, X2, Y2, CurPageStart)
// Далее мы определяем, какие ячейки в строках(попавших под выделение) попадают под выделение
// и заполняем SelectionData
+ var RowsSet = new Set(Rows);
for (var curRow = 0; curRow < this.Get_RowsCount(); curRow++)
{
// Проверка строки на наличие в массиве Rows
- if (Rows.indexOf(curRow) === -1)
+ if (!RowsSet.has(curRow))
continue;
@@ -13888,9 +13893,10 @@ CTable.prototype.CalculateNewRowsInfoByRowsIndices = function(X, RowsIndices)
for (var curRow = 0; curRow < this.Get_RowsCount(); curRow++)
{
+ var RowsIndicesSet = new Set(RowsIndices);
var cellsInfo = [];
for (var curCell = 0; curCell < this.GetRow(curRow).Get_CellsCount(); curCell++)
{
if ((X - this.GetRow(curRow).CellsInfo[curCell].X_cell_start > 1.5) && (this.GetRow(curRow).CellsInfo[curCell].X_cell_end - X > 1.5))
{
- if (RowsIndices.indexOf(curRow) != -1) //проверка на наличие строки curRow в массиве строк которые мы выделили
+ if (RowsIndicesSet.has(curRow)) //проверка на наличие строки curRow в массиве строк которые мы выделили
{