Skip to content

Commit

Permalink
Allow dot, solidus, percent and colon characters in profile names (#1067
Browse files Browse the repository at this point in the history
)
  • Loading branch information
trivikr authored Nov 9, 2023
1 parent 7de91ee commit c27879f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-beans-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/shared-ini-file-loader": patch
---

Allow dot, solidus, percent and colon characters in profile names
23 changes: 15 additions & 8 deletions packages/shared-ini-file-loader/src/parseIni.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ describe(parseIni.name, () => {
// 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);
expect(parseIni(mockInput)).toStrictEqual({
[["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData,
});
});
// `.` https://github.com/aws/aws-sdk-js-v3/issues/5449
// `/` https://github.com/awslabs/smithy-typescript/issues/1053
// `%` https://github.com/aws/aws-sdk-java-v2/pull/1538
// `:` https://github.com/aws/aws-sdk-java-v2/pull/1898
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);
expect(parseIni(mockInput)).toStrictEqual({
[["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData,
});
}
);

it("returns data for two profiles", () => {
const mockProfile1 = getMockProfileContent(mockProfileName, mockProfileData);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-ini-file-loader/src/parseIni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IniSectionType, ParsedIniData } from "@smithy/types";

import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles";

const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+]+)\2$/;
const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
const profileNameBlockList = ["__proto__", "profile __proto__"];

export const parseIni = (iniData: string): ParsedIniData => {
Expand Down

0 comments on commit c27879f

Please sign in to comment.