Skip to content
Open
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
7 changes: 6 additions & 1 deletion cli/src/stockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class StockData {
}

static async getStockQuote(tickers: string[]) {
const tickers_array = tickers.join(',');
// Validate each ticker: only allow alphanumeric characters, dots, hyphens, and carets
const validTickers = tickers.map(t => t.trim()).filter(t => /^[A-Z0-9.^-]{1,10}$/i.test(t));
if (validTickers.length !== tickers.length) {
throw new Error('One or more ticker symbols contain invalid characters.');
}
const tickers_array = encodeURIComponent(validTickers.join(','));
const url = `${this.yf_quote_url}${tickers_array}${this.yf_quote_ending_url}`;

const response = await axios.get(url);
Expand Down