Skip to content

Commit 715c501

Browse files
Improve input validation to prevent partial numeric strings
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
1 parent 1ad2ed7 commit 715c501

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

app/src/components/SettingsDrawer/Settings.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,11 @@ class Settings extends React.PureComponent<Props, State> {
254254
}
255255

256256
private onBlurMaxMessageSize = () => {
257-
const value = parseInt(this.state.maxMessageSizeInput, 10)
257+
const inputValue = this.state.maxMessageSizeInput.trim()
258+
const value = parseInt(inputValue, 10)
258259

259-
// Validate and update the setting, or reset to current value if invalid
260-
if (!isNaN(value) && value >= MAX_MESSAGE_SIZE_MIN && value <= MAX_MESSAGE_SIZE_MAX) {
260+
// Validate: ensure the entire string is a valid number and within range
261+
if (inputValue !== '' && !isNaN(value) && String(value) === inputValue && value >= MAX_MESSAGE_SIZE_MIN && value <= MAX_MESSAGE_SIZE_MAX) {
261262
this.props.actions.settings.setMaxMessageSize(value)
262263
} else {
263264
// Reset to current valid value without triggering backend updates

0 commit comments

Comments
 (0)