{"record":{"id":"382dbb1ae141d41d","repo":"kgretzky/evilginx2","slug":"invalid-command-line-string","errorCode":null,"errorMessage":"invalid command line string","messagePattern":"invalid command line string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser/parser.go","lineNumber":85,"sourceCode":"\t\t\tif !doubleQuoted {\n\t\t\t\tif singleQuoted {\n\t\t\t\t\tgot = true\n\t\t\t\t}\n\t\t\t\tsingleQuoted = !singleQuoted\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tgot = true\n\t\tbuf += string(r)\n\t}\n\n\tif got {\n\t\targs = append(args, buf)\n\t}\n\n\tif escaped || singleQuoted || doubleQuoted {\n\t\treturn nil, errors.New(\"invalid command line string\")\n\t}\n\n\treturn args, nil\n}\n\nfunc Parse(line string) ([]string, error) {\n\treturn NewParser().Parse(line)\n}\n","sourceCodeStart":67,"sourceCodeEnd":94,"githubUrl":"https://github.com/kgretzky/evilginx2/blob/4c0988a1d9db4d172a185e979a38bfd0efdb5830/parser/parser.go#L67-L94","documentation":"Parse tokenizes a shell-like command line string into arguments and throws this error when the input ends while the parser is still inside an unterminated escape sequence or quoted section. The library rejects such input because the intended argument boundaries are ambiguous, so it cannot return a faithful argv slice. It is raised at the very end of tokenization, after all characters have been consumed.","triggerScenarios":"Calling Parse (directly or via DoWork / importParamsFromFile) with a line containing a backslash at end of input (dangling escape), an opening single quote without a closing one (e.g. \"foo 'bar\"), or an opening double quote without a closing one (e.g. \"say \\\"hello\").","commonSituations":"Users pasting commands from documentation where quotes were mangled; programmatically built command lines with unescaped quotes in URLs or hostnames; editing a config/script and accidentally deleting a closing quote; copy-paste truncation of long lines.","solutions":["Check the input line for a matching closing quote for every opening single/double quote and re-run Parse","Remove or double-escape trailing backslashes before the end of the line","If the line comes from a file (importParamsFromFile), inspect the offending line in the file and fix quoting there","Wrap quotes properly when building commands programmatically, e.g. use strconv.Quote or shell-quoting helpers"],"exampleFix":"// before\nargs, err := parser.Parse(\"proxy 80 'phish.example.com)\")\n// after\nargs, err := parser.Parse(\"proxy 80 'phish.example.com'\")","handlingStrategy":"validation","validationCode":"func isBalancedLine(line string) bool {\n    var sq, dq bool\n    for i := 0; i < len(line); i++ {\n        c := line[i]\n        if c == '\\\\' { i++; continue }\n        if c == '\\'' && !dq { sq = !sq }\n        if c == '\"' && !sq { dq = !dq }\n    }\n    return !sq && !dq\n}\nif !isBalancedLine(line) { /* reject before Parse */ }","typeGuard":"func parseSafe(line string) ([]string, error) {\n    if !isBalancedLine(line) {\n        return nil, fmt.Errorf(\"unbalanced quotes in line: %q\", line)\n    }\n    return parser.Parse(line)\n}","tryCatchPattern":"args, err := parser.Parse(line)\nif err != nil {\n    if err.Error() == \"invalid command line string\" {\n        log.Printf(\"quoting problem in line: %q\", line)\n        return\n    }\n    return err\n}","preventionTips":["Always close quotes on the same logical line","Escape embedded quotes and backslashes (\\\\ and \\\\\")","Lint command files passed to importParamsFromFile for unbalanced quotes","When building lines programmatically, use a quoting helper instead of string concatenation"],"tags":["parsing","command-line","quoting"],"backgroundTag":"unterminated-string-literal","analyzedSha":"4c0988a1d9db4d172a185e979a38bfd0efdb5830","analyzedAt":"2026-09-05T19:23:07.238Z","contentChangedAt":"2026-09-05T19:23:07.238Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}