Skip to content
Snippets Groups Projects
Commit ae71895f authored by Eelco Dolstra's avatar Eelco Dolstra Committed by GitHub
Browse files

Merge pull request #947 from layus/fix-path-slash

Improve error message on trailing path slashes
parents 215b70f5 e4b82af3
No related branches found
No related tags found
No related merge requests found
...@@ -87,8 +87,8 @@ static Expr * unescapeStr(SymbolTable & symbols, const char * s) ...@@ -87,8 +87,8 @@ static Expr * unescapeStr(SymbolTable & symbols, const char * s)
ID [a-zA-Z\_][a-zA-Z0-9\_\'\-]* ID [a-zA-Z\_][a-zA-Z0-9\_\'\-]*
INT [0-9]+ INT [0-9]+
FLOAT (([1-9][0-9]*\.[0-9]*)|(0?\.[0-9]+))([Ee][+-]?[0-9]+)? FLOAT (([1-9][0-9]*\.[0-9]*)|(0?\.[0-9]+))([Ee][+-]?[0-9]+)?
PATH [a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+ PATH [a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+\/?
HPATH \~(\/[a-zA-Z0-9\.\_\-\+]+)+ HPATH \~(\/[a-zA-Z0-9\.\_\-\+]+)+\/?
SPATH \<[a-zA-Z0-9\.\_\-\+]+(\/[a-zA-Z0-9\.\_\-\+]+)*\> SPATH \<[a-zA-Z0-9\.\_\-\+]+(\/[a-zA-Z0-9\.\_\-\+]+)*\>
URI [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+ URI [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+
...@@ -182,8 +182,16 @@ or { return OR_KW; } ...@@ -182,8 +182,16 @@ or { return OR_KW; }
<INITIAL,INSIDE_DOLLAR_CURLY>{ <INITIAL,INSIDE_DOLLAR_CURLY>{
{PATH} { yylval->path = strdup(yytext); return PATH; } {PATH} { if (yytext[yyleng-1] == '/')
{HPATH} { yylval->path = strdup(yytext); return HPATH; } throw ParseError(format("Invalid path '%1%'; trailing slashes are not allowed in paths") % yytext);
yylval->path = strdup(yytext);
return PATH;
}
{HPATH} { if (yytext[yyleng-1] == '/')
throw ParseError(format("Invalid path '%1%'; trailing slashes are not allowed in paths") % yytext);
yylval->path = strdup(yytext);
return HPATH;
}
{SPATH} { yylval->path = strdup(yytext); return SPATH; } {SPATH} { yylval->path = strdup(yytext); return SPATH; }
{URI} { yylval->uri = strdup(yytext); return URI; } {URI} { yylval->uri = strdup(yytext); return URI; }
......
# Trailing slashes in paths are not allowed.
# This restriction could be lifted sometime,
# for example if we make '/' a path concatenation operator.
# See https://github.com/NixOS/nix/issues/1138
# and http://lists.science.uu.nl/pipermail/nix-dev/2016-June/020829.html
/nix/store/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment