From cd1a4069fc76673bfd2726f59a5d97857428095d Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:19:13 +0000 Subject: [PATCH] Parse profile name with invalid '+' character --- .changeset/pretty-yaks-fix.md | 5 +++++ packages/shared-ini-file-loader/src/parseIni.spec.ts | 7 ++++--- packages/shared-ini-file-loader/src/parseIni.ts | 4 +--- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/pretty-yaks-fix.md diff --git a/.changeset/pretty-yaks-fix.md b/.changeset/pretty-yaks-fix.md new file mode 100644 index 00000000000..d5c9b9fec84 --- /dev/null +++ b/.changeset/pretty-yaks-fix.md @@ -0,0 +1,5 @@ +--- +"@smithy/shared-ini-file-loader": patch +--- + +Parse profile name with invalid '+' character diff --git a/packages/shared-ini-file-loader/src/parseIni.spec.ts b/packages/shared-ini-file-loader/src/parseIni.spec.ts index b2f12ed335e..cf075b4659c 100644 --- a/packages/shared-ini-file-loader/src/parseIni.spec.ts +++ b/packages/shared-ini-file-loader/src/parseIni.spec.ts @@ -58,9 +58,10 @@ describe(parseIni.name, () => { } ); - // Character `@` is not allowed in profile name, but some customers are using it. - // Refs: https://github.com/awslabs/smithy-typescript/issues/1026 - it.each(["-", "_", "@"])("returns data for character '%s' in profile name", (specialChar: string) => { + // Some characters are not allowed in profile name, but we parse them as customers use them. + // `@` https://github.com/awslabs/smithy-typescript/issues/1026 + // `+` https://github.com/aws/aws-sdk-js-v3/issues/5373 + it.each(["-", "_", "@", "+"])("returns data for character '%s' in profile name", (specialChar: string) => { const mockProfileName = ["profile", "stage"].join(specialChar); const mockSectionFullName = ["profile", mockProfileName].join(" "); const mockInput = getMockProfileContent(mockSectionFullName, mockProfileData); diff --git a/packages/shared-ini-file-loader/src/parseIni.ts b/packages/shared-ini-file-loader/src/parseIni.ts index 1cef42ada7f..afd28d01db1 100644 --- a/packages/shared-ini-file-loader/src/parseIni.ts +++ b/packages/shared-ini-file-loader/src/parseIni.ts @@ -2,9 +2,7 @@ import { IniSectionType, ParsedIniData } from "@smithy/types"; import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles"; -// Character `@` is not allowed in profile name, but some customers are using it. -// Refs: https://github.com/awslabs/smithy-typescript/issues/1026 -const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@]+)\2$/; +const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+]+)\2$/; const profileNameBlockList = ["__proto__", "profile __proto__"]; export const parseIni = (iniData: string): ParsedIniData => {