File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ const VALID_UTM_CHARACTERS = /^[a-zA-Z0-9\s\-_.]+$/;
1717 */
1818const INVALID_UTM_CHARACTERS = / [ ^ a - z A - Z 0 - 9 \s \- _ . ] / g;
1919
20+ /**
21+ * Maximum allowed length for UTM parameter values
22+ */
23+ const MAX_UTM_VALUE_LENGTH = 200 ;
24+
2025/**
2126 * Validates UTM parameters
2227 * @param utm - Data form where user went to sign up. Used for analytics purposes
@@ -53,7 +58,7 @@ export function validateUtmParams(utm: UserDBScheme['utm']): boolean {
5358 }
5459
5560 // Check length
56- if ( value . length === 0 || value . length > 200 ) {
61+ if ( value . length === 0 || value . length > MAX_UTM_VALUE_LENGTH ) {
5762 return false ;
5863 }
5964
@@ -82,7 +87,10 @@ export function sanitizeUtmParams(utm: UserDBScheme['utm']): UserDBScheme['utm']
8287 for ( const [ key , value ] of Object . entries ( utm ) ) {
8388 if ( VALID_UTM_KEYS . includes ( key ) && value && typeof value === 'string' ) {
8489 // Sanitize value: keep only allowed characters and limit length
85- const cleanValue = value . replace ( INVALID_UTM_CHARACTERS , '' ) . trim ( ) . substring ( 0 , 200 ) ;
90+ const cleanValue = value
91+ . replace ( INVALID_UTM_CHARACTERS , '' )
92+ . trim ( )
93+ . substring ( 0 , MAX_UTM_VALUE_LENGTH ) ;
8694
8795 if ( cleanValue . length > 0 ) {
8896 ( sanitized as any ) [ key ] = cleanValue ;
You can’t perform that action at this time.
0 commit comments