-
Notifications
You must be signed in to change notification settings - Fork 376
start-proxy: Fix bug when language is not provided #2723
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,10 +51,19 @@ export function getCredentials( | |
} | ||
|
||
// Parse and validate the credentials | ||
const parsed = JSON.parse(credentialsStr) as Credential[]; | ||
let parsed: Credential[]; | ||
try { | ||
parsed = JSON.parse(credentialsStr) as Credential[]; | ||
} catch { | ||
// Don't log the error since it might contain sensitive information. | ||
logger.error("Failed to parse the credentials data."); | ||
throw new Error("Invalid credentials format."); | ||
marcogario marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
const out: Credential[] = []; | ||
for (const e of parsed) { | ||
if (e.url === undefined && e.host === undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it also an error if both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure, I believe the proxy will use the url in that case. I will double check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment. |
||
// The proxy needs one of these to work. If both are defined, the url has the precedence. | ||
throw new Error("Invalid credentials - must specify host or url"); | ||
} | ||
|
||
|
@@ -64,6 +73,23 @@ export function getCredentials( | |
continue; | ||
} | ||
|
||
const isPrintable = (str: string | undefined): boolean => { | ||
return str ? /^[\x20-\x7E]*$/.test(str) : true; | ||
}; | ||
|
||
if ( | ||
!isPrintable(e.type) || | ||
!isPrintable(e.host) || | ||
!isPrintable(e.url) || | ||
!isPrintable(e.username) || | ||
!isPrintable(e.password) || | ||
!isPrintable(e.token) | ||
) { | ||
throw new Error( | ||
marcogario marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Invalid credentials - fields must contain only printable characters", | ||
); | ||
} | ||
|
||
out.push({ | ||
type: e.type, | ||
host: e.host, | ||
|
Uh oh!
There was an error while loading. Please reload this page.