Skip to content

Commit d9d0f31

Browse files
committed
[FIX] range: invalid sheet name with special character
If we have a range with an invalid sheet name, the sheet name is not escaped with quotes when it contains special characters when converting the range back to a string. closes #7337 Task: 5125762 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent 63817f3 commit d9d0f31

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/plugins/core/range.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class RangeAdapter implements CommandHandler<CoreCommand> {
357357
let sheetName: string = "";
358358
if (prefixSheet) {
359359
if (rangeImpl.invalidSheetName) {
360-
sheetName = rangeImpl.invalidSheetName;
360+
sheetName = getCanonicalSheetName(rangeImpl.invalidSheetName);
361361
} else {
362362
sheetName = getCanonicalSheetName(this.getters.getSheetName(rangeImpl.sheetId));
363363
}

tests/model/model_import_export.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ describe("Migrations", () => {
287287

288288
const cfs = data.sheets[1].conditionalFormats;
289289
const rule1 = cfs[0].rule as ColorScaleRule;
290-
expect(cfs[0].ranges).toEqual(["=sheetName_!A1:A2"]);
290+
expect(cfs[0].ranges).toEqual(["'=sheetName_'!A1:A2"]);
291291
expect(rule1.minimum.value).toEqual("=sheetName_!B1");
292292
expect(rule1.midpoint?.value).toEqual("=sheetName_!B1");
293293
expect(rule1.maximum.value).toEqual("=sheetName_!B1");
@@ -298,7 +298,7 @@ describe("Migrations", () => {
298298
expect(rule2.upperInflectionPoint.value).toEqual("=sheetName_!B1");
299299

300300
const rule3 = cfs[2].rule as ColorScaleRule;
301-
expect(cfs[2].ranges).toEqual(["=sheetName_!A1:A2"]);
301+
expect(cfs[2].ranges).toEqual(["'=sheetName_'!A1:A2"]);
302302
expect(rule3.minimum.value).toEqual("33");
303303
expect(rule3.midpoint?.value).toEqual("13");
304304
expect(rule3.maximum.value).toBeUndefined();

tests/range_plugin.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,16 @@ describe("range plugin", () => {
551551
}
552552
);
553553

554+
test("invalid sheet name with special character", () => {
555+
const range = m.getters.getRangeFromSheetXC("s1", "'Invalid Sheet Name'!A1");
556+
expect(m.getters.getRangeString(range, "s1")).toBe("'Invalid Sheet Name'!A1");
557+
});
558+
554559
test.each([
555560
["s1!!!A1:A9", "'s1!!'!A1:A9"],
556561
["'s1!!'!A1:A9", "'s1!!'!A1:A9"],
557-
["s1!!!A1:s1!!!A9", "s1!!!A1:s1!!!A9"],
558-
["s1!!!A1:s1!!!A9", "s1!!!A1:s1!!!A9"],
562+
["s1!!!A1:s1!!!A9", "'s1!!!A1:s1!!'!A9"],
563+
["s1!!!A1:s1!!!A9", "'s1!!!A1:s1!!'!A9"],
559564
])(
560565
"xc with more than one exclamation mark does not throw error",
561566
(rangeString, expectedString) => {

0 commit comments

Comments
 (0)