Skip to content

Commit 33ed3f8

Browse files
committed
[wue] filter out '&' characters as part of a username
* Closes #2991. * Also factorize the list of characters we filter between wue.c and stdlg.c.
1 parent ffab56f commit 33ed3f8

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/rufus.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
#endif
151151
#define SYMBOL_SERVER_USER_AGENT "Microsoft-Symbol-Server/10.0.22621.755"
152152
#define DEFAULT_ESP_MOUNT_POINT "S:\\"
153+
// Per https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-useraccounts-localaccounts-localaccount-name
154+
// and https://learn.microsoft.com/en-us/previous-versions/cc722458(v=technet.10)#user-name-policies
155+
// Add '.' to the list because some folks also reported an issue with local accounts that have dots.
156+
// Also add '&', even as it could be escaped, as it's just not worth the trouble...
157+
#define USERNAME_INVALID_CHARS "/\\[]:;|=.,+*?<>%@&\""
153158
#define IS_POWER_OF_2(x) ((x != 0) && (((x) & ((x) - 1)) == 0))
154159
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
155160
#ifndef ARRAYSIZE

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.15.2383"
36+
CAPTION "Rufus 4.15.2384"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -409,8 +409,8 @@ END
409409
//
410410

411411
VS_VERSION_INFO VERSIONINFO
412-
FILEVERSION 4,15,2383,0
413-
PRODUCTVERSION 4,15,2383,0
412+
FILEVERSION 4,15,2384,0
413+
PRODUCTVERSION 4,15,2384,0
414414
FILEFLAGSMASK 0x3fL
415415
#ifdef _DEBUG
416416
FILEFLAGS 0x1L
@@ -428,13 +428,13 @@ BEGIN
428428
VALUE "Comments", "https://rufus.ie"
429429
VALUE "CompanyName", "Akeo Consulting"
430430
VALUE "FileDescription", "Rufus"
431-
VALUE "FileVersion", "4.15.2383"
431+
VALUE "FileVersion", "4.15.2384"
432432
VALUE "InternalName", "Rufus"
433433
VALUE "LegalCopyright", "� 2011-2026 Pete Batard (GPL v3)"
434434
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
435435
VALUE "OriginalFilename", "rufus-4.15.exe"
436436
VALUE "ProductName", "Rufus"
437-
VALUE "ProductVersion", "4.15.2383"
437+
VALUE "ProductVersion", "4.15.2384"
438438
END
439439
END
440440
BLOCK "VarFileInfo"

src/stdlg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,7 @@ static INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam
845845
{
846846
// This "Mooo" is designed to give us enough space for a regular username length
847847
static const char* base_username = "MOOOOOOOOOOO"; // 🐮
848-
// https://learn.microsoft.com/en-us/previous-versions/cc722458(v=technet.10)#user-name-policies
849-
static const char* username_invalid_chars = "/\\[]:;|=,+*?<>\"";
848+
static const char* username_invalid_chars = USERNAME_INVALID_CHARS;
850849
// Prevent resizing
851850
static const LRESULT disabled[9] = { HTLEFT, HTRIGHT, HTTOP, HTBOTTOM, HTSIZE,
852851
HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT };

src/wue.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ char* CreateUnattendXml(int arch, int flags)
347347
uprintf("WARNING: '%s' is not allowed as local account name - Option ignored", unattend_username);
348348
} else if (unattend_username[0] != 0) {
349349
char* org_username = safe_strdup(unattend_username);
350-
// Per https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-useraccounts-localaccounts-localaccount-name
351-
// Add '.' to the list because some folks also reported an issue with local accounts that have dots...
352-
filter_chars(unattend_username, "/\\[]:|<>+=;,?*%@.", '_');
350+
filter_chars(unattend_username, USERNAME_INVALID_CHARS, '_');
353351
uprintf("• Use '%s' for local account name", unattend_username);
354352
if (strcmp(org_username, unattend_username) != 0)
355353
uprintf("WARNING: Local account name contained unallowed characters and has been sanitized");

0 commit comments

Comments
 (0)