Skip to content

Commit

Permalink
Parse profile name with invalid '+' character (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Oct 19, 2023
1 parent 9c303eb commit 901cb6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-yaks-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/shared-ini-file-loader": patch
---

Parse profile name with invalid '+' character
7 changes: 4 additions & 3 deletions packages/shared-ini-file-loader/src/parseIni.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions packages/shared-ini-file-loader/src/parseIni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 901cb6c

Please sign in to comment.