Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes XML character escaping in 'spo listitem batch set' command. #6454

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/m365/spo/commands/listitem/listitem-batch-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ describe(commands.LISTITEM_BATCH_SET, () => {
assert.notStrictEqual(command.description, null);
});

it('updates single item in batch to a sharepoint list retrieved by listUrl including empty values', async () => {
it('updates single item in batch to a sharepoint list retrieved by listUrl including empty values and special characters', async () => {
const csvContentHeadersEmptyValues = `Id,ContentType,Title,SingleChoiceField`;
const csvContentLineEmptyValues = `10,Item,Title A,`;
const csvContentLineEmptyValues = `10,Item,Title A <>&",`;
const csvContentEmptyValues = `${csvContentHeadersEmptyValues}\n${csvContentLineEmptyValues}`;
const listServerRelativeUrl: string = urlUtil.getServerRelativePath(webUrl, listUrl);
const filterFields = ["InternalName eq 'ContentType'", "InternalName eq 'Title'", "InternalName eq 'SingleChoiceField'"];
Expand Down Expand Up @@ -136,6 +136,7 @@ describe(commands.LISTITEM_BATCH_SET, () => {

await command.action(logger, { options: { webUrl: webUrl, filePath: filePath, listUrl: listUrl, idColumn: idColumn, systemUpdate: true, verbose: true } } as any);
assert(postStub.called);
assert(postStub.args[0][0].data.includes('Title A &lt;&gt;&amp;&quot;'));
});

it('system updates single item in batch to a sharepoint list retrieved by id without user fields', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/m365/spo/commands/listitem/listitem-batch-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SpoListItemBatchSetCommand extends SpoCommand {
actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="Array">${lookupMultiString.join('')}</Parameter></Parameters></Method>`;
break;
default:
actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${(<any>row)[field.InternalName].toString()}</Parameter></Parameters></Method>`;
actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${formatting.escapeXml((<any>row)[field.InternalName].toString())}</Parameter></Parameters></Method>`;
break;
}
}
Expand Down