2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +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:
John Johansen 2018-01-08 03:34:59 -08:00
parent efd8eedd52
commit 8d142809f5
15 changed files with 105 additions and 3 deletions

View File

@ -200,7 +200,7 @@ MODES {MODE_CHARS}+
WS [[:blank:]]
NUMBER [[:digit:]]+
ID_CHARS [^ \t\n"!,]
ID_CHARS [^ \t\r\n"!,]
ID {ID_CHARS}|(,{ID_CHARS}|\\[ ]|\\\t|\\\"|\\!|\\,)
IDS {ID}+
POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+]
@ -274,13 +274,19 @@ LT_EQUAL <=
}
<INCLUDE>{
(\<([^\> \t\n]+)\>|\"([^\" \t\n]+)\") { /* <filename> */
(\<([^"\>\t\r\n]+)\>|{QUOTED_ID}) { /* <filename> | "filename" */
autofree char *filename = strndup(yytext, yyleng - 1);
include_filename(filename + 1, *filename == '<');
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);
POP_NODUMP();
}

View 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"
}

View 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
}

View 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">
}

View 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
}

View 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>
}

View 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
}

View File

@ -0,0 +1,6 @@
#
#=DESCRIPTION A helper for includes_okay.sd
#
#include <includes/fonts>
/tmp/** r,

View 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"
}

View 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
}

View 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">
}

View 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
}

View 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>
}

View 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
}

View File

@ -0,0 +1,6 @@
#
#=DESCRIPTION A helper for includes_okay.sd
#
#include <includes/fonts>
/tmp/** r,