Repository: quarkusio/quarkus
Issue: StringIndexOutOfBoundsException in invalid parameter declaration Qute parsing 

### Describe the bug

Given this Qute template:

```
{@
}
```

When Qute parse this invalid content, it throws:

```
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 1
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
	at java.base/java.lang.String.substring(String.java:1874)
	at io.quarkus.qute.Parser.flushTag(Parser.java:480)
	at io.quarkus.qute.Parser.tag(Parser.java:293)
	at io.quarkus.qute.Parser.processCharacter(Parser.java:200)
	at io.quarkus.qute.Parser.parse(Parser.java:132)
	at io.quarkus.qute.EngineImpl.parse(EngineImpl.java:56)
	at io.quarkus.qute.Engine.parse(Engine.java:30)
```

It's annoying to have this error when you are using Qute parser in an editor.

### Expected behavior

Take acre of StringIndexOutOfBoundsException and report an error.

### Actual behavior

```
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 1
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
	at java.base/java.lang.String.substring(String.java:1874)
	at io.quarkus.qute.Parser.flushTag(Parser.java:480)
	at io.quarkus.qute.Parser.tag(Parser.java:293)
	at io.quarkus.qute.Parser.processCharacter(Parser.java:200)
	at io.quarkus.qute.Parser.parse(Parser.java:132)
	at io.quarkus.qute.EngineImpl.parse(EngineImpl.java:56)
	at io.quarkus.qute.Engine.parse(Engine.java:30)
```

### How to Reproduce?

Parse Qute template content:

```
{@
}
```


### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java, independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java

diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java
index b69b5e9100c..fa4461a393a 100644
--- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java
+++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java
@@ -477,9 +477,12 @@ private void flushTag() {
             // Parameter declaration
             // {@org.acme.Foo foo}
             Scope currentScope = scopeStack.peek();
-            int spaceIdx = content.indexOf(" ");
-            String key = content.substring(spaceIdx + 1, content.length());
-            String value = content.substring(1, spaceIdx);
+            String[] parts = content.substring(1).trim().split("[ ]{1,}");
+            if (parts.length != 2) {
+                throw parserError("invalid parameter declaration " + START_DELIMITER + buffer.toString() + END_DELIMITER);
+            }
+            String value = parts[0];
+            String key = parts[1];
             currentScope.putBinding(key, Expressions.typeInfoFrom(value));
             sectionStack.peek().currentBlock().addNode(new ParameterDeclarationNode(content, origin(0)));
         } else {
diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java
index aba4d4f4e63..1a12c2952f0 100644
--- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java
+++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java
@@ -358,6 +358,20 @@ public void testInvalidBracket() {
                 "Parser error on line 1: invalid bracket notation expression in {foo.baz[}", 1);
     }
 
+    @Test
+    public void testInvalidParamDeclaration() {
+        assertParserError("{@com.foo }",
+                "Parser error on line 1: invalid parameter declaration {@com.foo }", 1);
+        assertParserError("{@ com.foo }",
+                "Parser error on line 1: invalid parameter declaration {@ com.foo }", 1);
+        assertParserError("{@com.foo.Bar bar baz}",
+                "Parser error on line 1: invalid parameter declaration {@com.foo.Bar bar baz}", 1);
+        assertParserError("{@}",
+                "Parser error on line 1: invalid parameter declaration {@}", 1);
+        assertParserError("{@\\n}",
+                "Parser error on line 1: invalid parameter declaration {@\\n}", 1);
+    }
+
     public static class Foo {
 
         public List<Item> getItems() {