Commit fd108a12 authored by jan.koester's avatar jan.koester
Browse files

validation fix

parent de74be19
Loading
Loading
Loading
Loading
+8 −1
Changes for parser.cpp: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -711,8 +711,15 @@ bool Parser::parse_target_var(const std::string& rest, std::string& name,
            name = trim(rest.substr(0, opstart));
            value = trim(rest.substr(i + 1));
            if (name.empty()) return false;
            // GNU make variable names may contain '-' (e.g. 'asflags-y') and
            // can be computed via '$(...)' references (e.g.
            // 'asflags-$(CONFIG_X86_64)'). Reject only characters that cannot
            // appear in an assignment LHS (whitespace was already trimmed).
            for (char nc : name) {
                if (!(std::isalnum(static_cast<unsigned char>(nc)) || nc == '_' || nc == '.'))
                if (std::isalnum(static_cast<unsigned char>(nc)) || nc == '_' ||
                    nc == '.' || nc == '-' || nc == '$' || nc == '(' || nc == ')' ||
                    nc == '{' || nc == '}' || nc == '/')
                    continue;
                return false;
            }
            return true;