Skip to content

Commit

Permalink
Double slash comments are silently breaking script execution #388
Browse files Browse the repository at this point in the history
  • Loading branch information
dprzybyl committed Jul 4, 2023
1 parent fa18be7 commit 3904e0e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ object ApmLangParserFactory {
throw InvalidSyntaxException(InputMismatchException(recognizer))
}

override fun reportError(recognizer: Parser?, e: RecognitionException?) {
throw InvalidSyntaxException(e!!)
}

override fun sync(recognizer: Parser) {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@ class ParsedScriptTest extends Specification {
file | output
"/invalid1.apm" | ["Invalid line [20:7]: DEFINE \$ nana", "Invalid sequence: \$"]
"/invalid2.apm" | ["Invalid line [20:7]: DEFINE / nana"]
"/invalid3.apm" | ["Invalid line [20:0]: // define variable", "Invalid sequence: //"]
"/invalid4.apm" | ["Invalid line [20:0]: / define variable"]
"/invalid5.apm" | ["Invalid line [20:0]: /x define variable", "Invalid sequence: /x"]
"/invalid6.apm" | ["Invalid line [20:0]: /* define variable", "Invalid sequence: /*"]
"/invalid7.apm" | ["Invalid line [20:0]: <!-- define variable"]
}
}
21 changes: 21 additions & 0 deletions app/aem/core/src/test/resources/invalid3.apm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# ========================LICENSE_START=================================
# AEM Permission Management
# %%
# Copyright (C) 2013 Wunderman Thompson Technology
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================LICENSE_END==================================

// define variable
DEFINE / nana
21 changes: 21 additions & 0 deletions app/aem/core/src/test/resources/invalid4.apm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# ========================LICENSE_START=================================
# AEM Permission Management
# %%
# Copyright (C) 2013 Wunderman Thompson Technology
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================LICENSE_END==================================

/ define variable
DEFINE / nana
21 changes: 21 additions & 0 deletions app/aem/core/src/test/resources/invalid5.apm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# ========================LICENSE_START=================================
# AEM Permission Management
# %%
# Copyright (C) 2013 Wunderman Thompson Technology
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================LICENSE_END==================================

/x define variable
DEFINE / nana
22 changes: 22 additions & 0 deletions app/aem/core/src/test/resources/invalid6.apm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# ========================LICENSE_START=================================
# AEM Permission Management
# %%
# Copyright (C) 2013 Wunderman Thompson Technology
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================LICENSE_END==================================

/* define variable
*/
DEFINE / nana
22 changes: 22 additions & 0 deletions app/aem/core/src/test/resources/invalid7.apm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# ========================LICENSE_START=================================
# AEM Permission Management
# %%
# Copyright (C) 2013 Wunderman Thompson Technology
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================LICENSE_END==================================

<!-- define variable
-->
DEFINE / nana

0 comments on commit 3904e0e

Please sign in to comment.