File tree Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Original file line number Diff line number Diff line change 1313#define ID_REFRESH_BUTTON 103
1414
1515// Global string variable
16- std::wstring globalPin = L" 111 " ;
16+ std::wstring globalPin = L" 0000 " ;
1717std::wstring deviceNumber = L" " ;
1818
1919HINSTANCE hInst;
@@ -25,6 +25,45 @@ struct PasskeyInfo {
2525 std::wstring domain;
2626};
2727
28+ std::wstring EscapeCommandLineArgument (const std::wstring& input) {
29+ std::wstring escaped = L" \" " ; // Start with a quote to properly handle spaces
30+
31+ for (wchar_t ch : input) {
32+ switch (ch) {
33+ case L' "' : escaped += L" \\\" " ; break ; // Escape double quotes
34+ case L' ^' :
35+ case L' &' :
36+ case L' |' :
37+ case L' <' :
38+ case L' >' :
39+ case L' %' :
40+ case L' !' :
41+ case L' (' :
42+ case L' )' :
43+ case L' =' :
44+ case L' ;' :
45+ case L' `' :
46+ case L' ,' :
47+ case L' [' :
48+ case L' ]' :
49+ case L' {' :
50+ case L' }' :
51+ case L' *' :
52+ case L' ?' :
53+ case L' \\ ' : // Escape special characters for CMD
54+ escaped += L' ^' ;
55+ escaped += ch;
56+ break ;
57+ default :
58+ escaped += ch;
59+ }
60+ }
61+
62+ escaped += L" \" " ; // End with a quote
63+ return escaped;
64+ }
65+
66+
2867
2968// Function to execute a command and capture its output
3069std::vector<std::wstring> RunCommandAndGetOutput (const std::wstring& command) {
@@ -659,6 +698,7 @@ void PopulateListView(HWND hwnd, const std::wstring& deviceNumber) {
659698 DisableAllButtons (hwnd);
660699 // Show the input box and store the result in globalPIN
661700 globalPin = ShowInputBox (NULL , L" Enter PIN" , L" Please enter your PIN:" );
701+ globalPin = EscapeCommandLineArgument (globalPin);
662702
663703 const size_t MIN_PIN_LENGTH = 4 ;
664704
You can’t perform that action at this time.
0 commit comments