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

Parse profile name with invalid '+' character #1047

Merged
merged 1 commit into from
Oct 19, 2023
Merged
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: 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
Loading