Skip to content

reject tokenVocab names containing a path separator#4957

Open
abdul7056 wants to merge 1 commit into
antlr:devfrom
abdul7056:tokenvocab-path-reject
Open

reject tokenVocab names containing a path separator#4957
abdul7056 wants to merge 1 commit into
antlr:devfrom
abdul7056:tokenvocab-path-reject

Conversation

@abdul7056

Copy link
Copy Markdown

The tokenVocab option value is used verbatim to build the .tokens path in TokenVocabParser:

  • getImportedVocabFile resolves it against libDirectory, outputDirectory and the grammar directory, none of which constrain the result
  • option values may be quoted string literals, so options { tokenVocab='../../secret/creds'; } resolves outside all three roots
  • lines that fail the token-definition regex are reported via TOKENS_FILE_SYNTAX_ERROR, putting the contents of the opened file into tool output

Rejecting names that carry a path separator before anything is opened. antlr4-maven-plugin already reduces this same value with stripPath, so a bare grammar name is the expected shape.

The option value is resolved against the lib, output and grammar directories, so a name with a path separator reads a .tokens file outside all three and unparsable lines are echoed into tool output.

Signed-off-by: abdul7056 <abdul@sproutxp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant