Code securisation (#843)
* Fix: securize convertToGroup method when manipulate element with no transform attribute * Fix: securise getIntersectionListMethod method when manipulate element with no bbox (for example : defs element) * Fix: securise resize method when there is no bbox (for example : defs element) * Fix: securise recalculateDimensions to avoid to pass null to addSubCommandmaster
parent
8350b97875
commit
ae243ce906
|
@ -359,7 +359,10 @@ export const recalculateDimensions = (selected) => {
|
||||||
childTlist.appendItem(scale)
|
childTlist.appendItem(scale)
|
||||||
childTlist.appendItem(translateOrigin)
|
childTlist.appendItem(translateOrigin)
|
||||||
} // not rotated
|
} // not rotated
|
||||||
batchCmd.addSubCommand(recalculateDimensions(child))
|
const recalculatedDimensions = recalculateDimensions(child)
|
||||||
|
if (recalculatedDimensions) {
|
||||||
|
batchCmd.addSubCommand(recalculatedDimensions)
|
||||||
|
}
|
||||||
svgCanvas.setStartTransform(oldStartTransform)
|
svgCanvas.setStartTransform(oldStartTransform)
|
||||||
} // element
|
} // element
|
||||||
} // for each child
|
} // for each child
|
||||||
|
@ -420,7 +423,10 @@ export const recalculateDimensions = (selected) => {
|
||||||
} else {
|
} else {
|
||||||
childTlist.appendItem(newxlate)
|
childTlist.appendItem(newxlate)
|
||||||
}
|
}
|
||||||
batchCmd.addSubCommand(recalculateDimensions(child))
|
const recalculatedDimensions = recalculateDimensions(child)
|
||||||
|
if (recalculatedDimensions) {
|
||||||
|
batchCmd.addSubCommand(recalculatedDimensions)
|
||||||
|
}
|
||||||
// If any <use> have this group as a parent and are
|
// If any <use> have this group as a parent and are
|
||||||
// referencing this child, then impose a reverse translate on it
|
// referencing this child, then impose a reverse translate on it
|
||||||
// so that when it won't get double-translated
|
// so that when it won't get double-translated
|
||||||
|
@ -464,7 +470,10 @@ export const recalculateDimensions = (selected) => {
|
||||||
childTlist.clear()
|
childTlist.clear()
|
||||||
childTlist.appendItem(e2m, 0)
|
childTlist.appendItem(e2m, 0)
|
||||||
|
|
||||||
batchCmd.addSubCommand(recalculateDimensions(child))
|
const recalculatedDimensions = recalculateDimensions(child)
|
||||||
|
if (recalculatedDimensions) {
|
||||||
|
batchCmd.addSubCommand(recalculatedDimensions)
|
||||||
|
}
|
||||||
svgCanvas.setStartTransform(oldStartTransform)
|
svgCanvas.setStartTransform(oldStartTransform)
|
||||||
|
|
||||||
// Convert stroke
|
// Convert stroke
|
||||||
|
@ -544,7 +553,10 @@ export const recalculateDimensions = (selected) => {
|
||||||
childTlist.appendItem(newxlate)
|
childTlist.appendItem(newxlate)
|
||||||
}
|
}
|
||||||
|
|
||||||
batchCmd.addSubCommand(recalculateDimensions(child))
|
const recalculatedDimensions = recalculateDimensions(child)
|
||||||
|
if (recalculatedDimensions) {
|
||||||
|
batchCmd.addSubCommand(recalculatedDimensions)
|
||||||
|
}
|
||||||
svgCanvas.setStartTransform(oldStartTransform)
|
svgCanvas.setStartTransform(oldStartTransform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ export class Selector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bbox) {
|
||||||
// apply the transforms
|
// apply the transforms
|
||||||
const l = bbox.x; const t = bbox.y; const w = bbox.width; const h = bbox.height
|
const l = bbox.x; const t = bbox.y; const w = bbox.width; const h = bbox.height
|
||||||
// bbox = {x: l, y: t, width: w, height: h}; // Not in use
|
// bbox = {x: l, y: t, width: w, height: h}; // Not in use
|
||||||
|
@ -246,7 +247,7 @@ export class Selector {
|
||||||
|
|
||||||
mgr.rotateGrip.setAttribute('cx', nbax + (nbaw) / 2)
|
mgr.rotateGrip.setAttribute('cx', nbax + (nbaw) / 2)
|
||||||
mgr.rotateGrip.setAttribute('cy', nbay - (gripRadius * 5))
|
mgr.rotateGrip.setAttribute('cy', nbay - (gripRadius * 5))
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATIC methods
|
// STATIC methods
|
||||||
|
|
|
@ -972,7 +972,7 @@ const convertToGroup = elem => {
|
||||||
} else if (dataStorage.has($elem, 'symbol')) {
|
} else if (dataStorage.has($elem, 'symbol')) {
|
||||||
elem = dataStorage.get($elem, 'symbol')
|
elem = dataStorage.get($elem, 'symbol')
|
||||||
|
|
||||||
ts = $elem.getAttribute('transform')
|
ts = $elem.getAttribute('transform') || ''
|
||||||
const pos = {
|
const pos = {
|
||||||
x: Number($elem.getAttribute('x')),
|
x: Number($elem.getAttribute('x')),
|
||||||
y: Number($elem.getAttribute('y'))
|
y: Number($elem.getAttribute('y'))
|
||||||
|
|
|
@ -324,7 +324,7 @@ const getIntersectionListMethod = (rect) => {
|
||||||
if (!rubberBBox.width) {
|
if (!rubberBBox.width) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
if (curBBoxes[i].bbox && rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
||||||
resultList.push(curBBoxes[i].elem)
|
resultList.push(curBBoxes[i].elem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue