mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 13:58:22 +00:00
parser tests: fix includes to allow white space
includes were not handling WS in path names correctly. Allow WS within quotes. Eg include "foo bar" include <"foo bar"> BugLink: http://bugs.launchpad.net/bugs/1738880 Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -200,7 +200,7 @@ MODES {MODE_CHARS}+
|
|||||||
WS [[:blank:]]
|
WS [[:blank:]]
|
||||||
NUMBER [[:digit:]]+
|
NUMBER [[:digit:]]+
|
||||||
|
|
||||||
ID_CHARS [^ \t\n"!,]
|
ID_CHARS [^ \t\r\n"!,]
|
||||||
ID {ID_CHARS}|(,{ID_CHARS}|\\[ ]|\\\t|\\\"|\\!|\\,)
|
ID {ID_CHARS}|(,{ID_CHARS}|\\[ ]|\\\t|\\\"|\\!|\\,)
|
||||||
IDS {ID}+
|
IDS {ID}+
|
||||||
POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+]
|
POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+]
|
||||||
@@ -274,13 +274,19 @@ LT_EQUAL <=
|
|||||||
}
|
}
|
||||||
|
|
||||||
<INCLUDE>{
|
<INCLUDE>{
|
||||||
(\<([^\> \t\n]+)\>|\"([^\" \t\n]+)\") { /* <filename> */
|
(\<([^"\>\t\r\n]+)\>|{QUOTED_ID}) { /* <filename> | "filename" */
|
||||||
autofree char *filename = strndup(yytext, yyleng - 1);
|
autofree char *filename = strndup(yytext, yyleng - 1);
|
||||||
include_filename(filename + 1, *filename == '<');
|
include_filename(filename + 1, *filename == '<');
|
||||||
POP_NODUMP();
|
POP_NODUMP();
|
||||||
}
|
}
|
||||||
|
|
||||||
[^\<\>\" \t\n]+ { /* filename */
|
(\<{QUOTED_ID}\>) { /* <"filename"> */
|
||||||
|
autofree char *filename = strndup(yytext, yyleng - 2);
|
||||||
|
include_filename(filename + 2, true);
|
||||||
|
POP_NODUMP();
|
||||||
|
}
|
||||||
|
|
||||||
|
({IDS}|{QUOTED_ID}) { /* filename */
|
||||||
include_filename(yytext, 0);
|
include_filename(yytext, 0);
|
||||||
POP_NODUMP();
|
POP_NODUMP();
|
||||||
}
|
}
|
||||||
|
7
parser/tst/simple_tests/bare_include_tests/ok_26.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_26.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include "simple_tests/include_tests/includes with space helper.include"
|
||||||
|
}
|
7
parser/tst/simple_tests/bare_include_tests/ok_27.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_27.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include "simple_tests/include_tests/includes with space helper.include" #comment
|
||||||
|
}
|
7
parser/tst/simple_tests/bare_include_tests/ok_28.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_28.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include <"include_tests/includes with space helper.include">
|
||||||
|
}
|
7
parser/tst/simple_tests/bare_include_tests/ok_29.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_29.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include <"include_tests/includes with space helper.include"> #comment
|
||||||
|
}
|
7
parser/tst/simple_tests/bare_include_tests/ok_30.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_30.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include <include_tests/includes with space helper.include>
|
||||||
|
}
|
7
parser/tst/simple_tests/bare_include_tests/ok_31.sd
Normal file
7
parser/tst/simple_tests/bare_include_tests/ok_31.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
include <include_tests/includes with space helper.include> #comment
|
||||||
|
}
|
@@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION A helper for includes_okay.sd
|
||||||
|
#
|
||||||
|
#include <includes/fonts>
|
||||||
|
|
||||||
|
/tmp/** r,
|
7
parser/tst/simple_tests/include_tests/ok_26.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_26.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include "simple_tests/include_tests/includes with space helper.include"
|
||||||
|
}
|
7
parser/tst/simple_tests/include_tests/ok_27.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_27.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include "simple_tests/include_tests/includes with space helper.include" #comment
|
||||||
|
}
|
7
parser/tst/simple_tests/include_tests/ok_28.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_28.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include <"include_tests/includes with space helper.include">
|
||||||
|
}
|
7
parser/tst/simple_tests/include_tests/ok_29.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_29.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include <"include_tests/includes with space helper.include"> #comment
|
||||||
|
}
|
7
parser/tst/simple_tests/include_tests/ok_30.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_30.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include <include_tests/includes with space helper.include>
|
||||||
|
}
|
7
parser/tst/simple_tests/include_tests/ok_31.sd
Normal file
7
parser/tst/simple_tests/include_tests/ok_31.sd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION includes testing - basic include of global and local include
|
||||||
|
#=EXRESULT PASS
|
||||||
|
#
|
||||||
|
/does/not/exist {
|
||||||
|
#include <include_tests/includes with space helper.include> #comment
|
||||||
|
}
|
@@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
#=DESCRIPTION A helper for includes_okay.sd
|
||||||
|
#
|
||||||
|
#include <includes/fonts>
|
||||||
|
|
||||||
|
/tmp/** r,
|
Reference in New Issue
Block a user