Skip to content

Commit 11977e7

Browse files
authored
v2.4 - add strlen check for prefs.js
cmd.exe has a command line length limit of 8192 characters. Abort if prefs.js contains strings that would get dropped while recreating the new prefs.js.
1 parent 27dd6aa commit 11977e7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

prefsCleaner.bat

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TITLE prefs.js cleaner
33

44
REM ### prefs.js cleaner for Windows
55
REM ## author: @claustromaniac
6-
REM ## version: 2.3
6+
REM ## version: 2.4
77

88
CD /D "%~dp0"
99

@@ -13,7 +13,7 @@ ECHO:
1313
ECHO ########################################
1414
ECHO #### prefs.js cleaner for Windows ####
1515
ECHO #### by claustromaniac ####
16-
ECHO #### v2.3 ####
16+
ECHO #### v2.4 ####
1717
ECHO ########################################
1818
ECHO:
1919
CALL :message "This script should be run from your Firefox profile directory."
@@ -28,6 +28,7 @@ IF ERRORLEVEL 3 (EXIT /B)
2828
IF ERRORLEVEL 2 (GOTO :showhelp)
2929
IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory." 30)
3030
IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30)
31+
CALL :strlenCheck
3132
CALL :FFcheck
3233
CALL :message "Backing up prefs.js..."
3334
SET "_time=%time: =0%"
@@ -50,6 +51,21 @@ ECHO:
5051
ECHO: %~1
5152
ECHO:
5253
GOTO :EOF
54+
REM ### string length Check Function ####
55+
:strlenCheck
56+
SET /a cnt=0
57+
setlocal ENABLEDELAYEDEXPANSION
58+
FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO (
59+
ECHO:%%H >nul
60+
SET /a cnt += 1
61+
IF /I "%%G" NEQ "!cnt!" (
62+
ECHO:
63+
CALL :message "ERROR: line !cnt! in prefs.js is too long."
64+
(CALL :abort "Aborting ..." 30)
65+
)
66+
)
67+
endlocal
68+
GOTO :EOF
5369
REM ####### Firefox Check Function ######
5470
:FFcheck
5571
TASKLIST /FI "IMAGENAME eq firefox.exe" 2>NUL | FIND /I /N "firefox.exe">NUL

0 commit comments

Comments
 (0)