Skip to content

Let APT macro blocks end at the last brace on the line - #1069

Open
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:fix-apt-macro-closing-brace
Open

Let APT macro blocks end at the last brace on the line#1069
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:fix-apt-macro-closing-brace

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

MacroBlock.traverse() located the end of the macro with indexOf('}'),
which is the first closing brace. A parameter value containing braces
therefore truncated the macro, silently dropping the rest of the value.

This shows up when the raw source of a *.apt.vm file is parsed, where
Velocity references are still unresolved:

%{snippet|file=${project.build.directory}/test-classes/resolve.txt}

parsed as file=${project.build.directory}, dropping the path. In a normal
site build Velocity runs first so no brace remains, but doxia-converter
parses the unprocessed source and lost the parameter.

The macro block always ends with the closing brace, so use lastIndexOf.

Part of the wider migration tracked in
apache/maven-doxia-converter#139

MacroBlock.traverse() located the end of the macro with indexOf('}'),
which is the *first* closing brace. A parameter value containing braces
therefore truncated the macro, silently dropping the rest of the value.

This shows up when the raw source of a *.apt.vm file is parsed, where
Velocity references are still unresolved:

  %{snippet|file=${project.build.directory}/test-classes/resolve.txt}

parsed as file=${project.build.directory}, dropping the path. In a normal
site build Velocity runs first so no brace remains, but doxia-converter
parses the unprocessed source and lost the parameter.

The macro block always ends with the closing brace, so use lastIndexOf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant