This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch docs/struts-7-5-configuration-grammar in repository https://gitbox.apache.org/repos/asf/struts-intellij-plugin.git
commit ca12ca3ebfd5f6329a62ec4eed49c638e6985e3c Author: Lukasz Lenart <[email protected]> AuthorDate: Wed Nov 11 10:16:02 2026 +0100 feat: register Struts 6.5 and 7.5 configuration DTDs Accept the published 6.5 and 7.5 DOCTYPEs from the bundled catalog copies. Co-authored-by: Cursor <[email protected]> --- .../intellij/struts2/Struts2ResourceProvider.java | 8 + .../java/com/intellij/struts2/StrutsConstants.java | 14 +- src/main/resources/resources/dtds/struts-6.5.dtd | 158 +++++++++++++++++++ src/main/resources/resources/dtds/struts-7.5.dtd | 167 +++++++++++++++++++++ .../dom/inspection/StrutsDtdValidatorTest.java | 48 ++++++ 5 files changed, 394 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/intellij/struts2/Struts2ResourceProvider.java b/src/main/java/com/intellij/struts2/Struts2ResourceProvider.java index 9d7ee05..77fda3d 100644 --- a/src/main/java/com/intellij/struts2/Struts2ResourceProvider.java +++ b/src/main/java/com/intellij/struts2/Struts2ResourceProvider.java @@ -54,6 +54,14 @@ final class Struts2ResourceProvider implements StandardResourceProvider { StrutsConstants.STRUTS_6_0_DTD_ID, "struts-6.0.dtd", registrar); + addDTDResource(StrutsConstants.STRUTS_6_5_DTD_URI, + StrutsConstants.STRUTS_6_5_DTD_ID, + "struts-6.5.dtd", registrar); + + addDTDResource(StrutsConstants.STRUTS_7_5_DTD_URI, + StrutsConstants.STRUTS_7_5_DTD_ID, + "struts-7.5.dtd", registrar); + addDTDResource(StrutsConstants.VALIDATOR_1_00_DTD_URI, StrutsConstants.VALIDATOR_1_00_DTD_ID, diff --git a/src/main/java/com/intellij/struts2/StrutsConstants.java b/src/main/java/com/intellij/struts2/StrutsConstants.java index cb0c81d..a86416c 100644 --- a/src/main/java/com/intellij/struts2/StrutsConstants.java +++ b/src/main/java/com/intellij/struts2/StrutsConstants.java @@ -120,6 +120,16 @@ public final class StrutsConstants { @NonNls public static final String STRUTS_6_0_DTD_ID = "-//Apache Software Foundation//DTD Struts Configuration 6.0//EN"; + @NonNls + public static final String STRUTS_6_5_DTD_URI = "https://struts.apache.org/dtds/struts-6.5.dtd"; + @NonNls + public static final String STRUTS_6_5_DTD_ID = "-//Apache Software Foundation//DTD Struts Configuration 6.5//EN"; + + @NonNls + public static final String STRUTS_7_5_DTD_URI = "https://struts.apache.org/dtds/struts-7.5.dtd"; + @NonNls + public static final String STRUTS_7_5_DTD_ID = "-//Apache Software Foundation//DTD Struts Configuration 7.5//EN"; + /** * All struts.xml DTD-IDs/URIs. */ @@ -130,7 +140,9 @@ public final class StrutsConstants { STRUTS_2_1_7_DTD_URI, STRUTS_2_1_7_DTD_ID, STRUTS_2_3_DTD_URI, STRUTS_2_3_DTD_ID, STRUTS_2_5_DTD_URI, STRUTS_2_5_DTD_ID, - STRUTS_6_0_DTD_URI, STRUTS_6_0_DTD_ID + STRUTS_6_0_DTD_URI, STRUTS_6_0_DTD_ID, + STRUTS_6_5_DTD_URI, STRUTS_6_5_DTD_ID, + STRUTS_7_5_DTD_URI, STRUTS_7_5_DTD_ID }; @NonNls diff --git a/src/main/resources/resources/dtds/struts-6.5.dtd b/src/main/resources/resources/dtds/struts-6.5.dtd new file mode 100644 index 0000000..6c2ef0d --- /dev/null +++ b/src/main/resources/resources/dtds/struts-6.5.dtd @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +--> +<!-- START SNIPPET: strutsDtd --> + +<!-- + Struts configuration DTD. + Use the following DOCTYPE + + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 6.5//EN" + "https://struts.apache.org/dtds/struts-6.5.dtd"> +--> + +<!ELEMENT struts ((package|include|bean|constant)*,bean-selection?, unknown-handler-stack?)> +<!ATTLIST struts + order CDATA #IMPLIED +> + +<!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, default-class-ref?, global-results?, global-allowed-methods?, global-exception-mappings?, action*)> +<!ATTLIST package + name CDATA #REQUIRED + extends CDATA #IMPLIED + namespace CDATA #IMPLIED + abstract CDATA #IMPLIED + final CDATA #IMPLIED + strict-method-invocation (true|false) "true" +> + +<!ELEMENT result-types (result-type+)> + +<!ELEMENT result-type (param*)> +<!ATTLIST result-type + name CDATA #REQUIRED + class CDATA #REQUIRED + default (true|false) "false" +> + +<!ELEMENT interceptors (interceptor|interceptor-stack)+> + +<!ELEMENT interceptor (param*)> +<!ATTLIST interceptor + name CDATA #REQUIRED + class CDATA #REQUIRED +> + +<!ELEMENT interceptor-stack (interceptor-ref*)> +<!ATTLIST interceptor-stack + name CDATA #REQUIRED +> + +<!ELEMENT interceptor-ref (param*)> +<!ATTLIST interceptor-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-interceptor-ref (#PCDATA)> +<!ATTLIST default-interceptor-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-action-ref (#PCDATA)> +<!ATTLIST default-action-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-class-ref (#PCDATA)> +<!ATTLIST default-class-ref + class CDATA #REQUIRED +> + +<!ELEMENT global-results (result+)> + +<!ELEMENT global-allowed-methods (#PCDATA)> + +<!ELEMENT global-exception-mappings (exception-mapping+)> + +<!ELEMENT action ((param|result|interceptor-ref|exception-mapping)*,allowed-methods?)> +<!ATTLIST action + name CDATA #REQUIRED + class CDATA #IMPLIED + method CDATA #IMPLIED + converter CDATA #IMPLIED +> + +<!ELEMENT param (#PCDATA)> +<!ATTLIST param + name CDATA #REQUIRED +> + +<!ELEMENT result (#PCDATA|param)*> +<!ATTLIST result + name CDATA #IMPLIED + type CDATA #IMPLIED +> + +<!ELEMENT exception-mapping (#PCDATA|param)*> +<!ATTLIST exception-mapping + name CDATA #IMPLIED + exception CDATA #REQUIRED + result CDATA #REQUIRED +> + +<!ELEMENT allowed-methods (#PCDATA)> + +<!ELEMENT include (#PCDATA)> +<!ATTLIST include + file CDATA #REQUIRED +> + +<!ELEMENT bean (#PCDATA)> +<!ATTLIST bean + type CDATA #IMPLIED + name CDATA #IMPLIED + class CDATA #REQUIRED + scope CDATA #IMPLIED + static CDATA #IMPLIED + optional CDATA #IMPLIED +> + +<!ELEMENT bean-selection (#PCDATA)> +<!ATTLIST bean-selection + name CDATA #IMPLIED + class CDATA #IMPLIED +> + +<!ELEMENT constant (#PCDATA)> +<!ATTLIST constant + name CDATA #REQUIRED + value CDATA #REQUIRED +> + +<!ELEMENT unknown-handler-stack (unknown-handler-ref*)> +<!ELEMENT unknown-handler-ref (#PCDATA)> +<!ATTLIST unknown-handler-ref + name CDATA #REQUIRED +> + +<!-- END SNIPPET: strutsDtd --> + diff --git a/src/main/resources/resources/dtds/struts-7.5.dtd b/src/main/resources/resources/dtds/struts-7.5.dtd new file mode 100644 index 0000000..4abfe46 --- /dev/null +++ b/src/main/resources/resources/dtds/struts-7.5.dtd @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +--> +<!-- START SNIPPET: strutsDtd --> + +<!-- + Struts configuration DTD. + Use the following DOCTYPE + + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 7.5//EN" + "https://struts.apache.org/dtds/struts-7.5.dtd"> +--> + +<!ELEMENT struts ((package|include|bean|constant)*,bean-selection?, unknown-handler-stack?)> +<!ATTLIST struts + order CDATA #IMPLIED +> + +<!ELEMENT package (scoped-constant*, result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, default-class-ref?, global-results?, global-allowed-methods?, global-exception-mappings?, action*)> +<!ATTLIST package + name CDATA #REQUIRED + extends CDATA #IMPLIED + namespace CDATA #IMPLIED + abstract CDATA #IMPLIED + final CDATA #IMPLIED + strict-method-invocation (true|false) "true" + extension CDATA #IMPLIED +> + +<!ELEMENT scoped-constant EMPTY> +<!ATTLIST scoped-constant + name CDATA #REQUIRED + value CDATA #REQUIRED +> + +<!ELEMENT result-types (result-type+)> + +<!ELEMENT result-type (param*)> +<!ATTLIST result-type + name CDATA #REQUIRED + class CDATA #REQUIRED + default (true|false) "false" +> + +<!ELEMENT interceptors (interceptor|interceptor-stack)+> + +<!ELEMENT interceptor (param*)> +<!ATTLIST interceptor + name CDATA #REQUIRED + class CDATA #REQUIRED +> + +<!ELEMENT interceptor-stack (interceptor-ref*)> +<!ATTLIST interceptor-stack + name CDATA #REQUIRED +> + +<!ELEMENT interceptor-ref (param*)> +<!ATTLIST interceptor-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-interceptor-ref (#PCDATA)> +<!ATTLIST default-interceptor-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-action-ref (#PCDATA)> +<!ATTLIST default-action-ref + name CDATA #REQUIRED +> + +<!ELEMENT default-class-ref (#PCDATA)> +<!ATTLIST default-class-ref + class CDATA #REQUIRED +> + +<!ELEMENT global-results (result+)> + +<!ELEMENT global-allowed-methods (#PCDATA)> + +<!ELEMENT global-exception-mappings (exception-mapping+)> + +<!ELEMENT action ((param|result|interceptor-ref|exception-mapping)*,allowed-methods?)> +<!ATTLIST action + name CDATA #REQUIRED + class CDATA #IMPLIED + method CDATA #IMPLIED + converter CDATA #IMPLIED + http-method CDATA #IMPLIED + extension CDATA #IMPLIED +> + +<!ELEMENT param (#PCDATA)> +<!ATTLIST param + name CDATA #REQUIRED +> + +<!ELEMENT result (#PCDATA|param)*> +<!ATTLIST result + name CDATA #IMPLIED + type CDATA #IMPLIED +> + +<!ELEMENT exception-mapping (#PCDATA|param)*> +<!ATTLIST exception-mapping + name CDATA #IMPLIED + exception CDATA #REQUIRED + result CDATA #REQUIRED +> + +<!ELEMENT allowed-methods (#PCDATA)> + +<!ELEMENT include (#PCDATA)> +<!ATTLIST include + file CDATA #REQUIRED +> + +<!ELEMENT bean (#PCDATA)> +<!ATTLIST bean + type CDATA #IMPLIED + name CDATA #IMPLIED + class CDATA #REQUIRED + scope CDATA #IMPLIED + static CDATA #IMPLIED + optional CDATA #IMPLIED +> + +<!ELEMENT bean-selection (#PCDATA)> +<!ATTLIST bean-selection + name CDATA #IMPLIED + class CDATA #IMPLIED +> + +<!ELEMENT constant (#PCDATA)> +<!ATTLIST constant + name CDATA #REQUIRED + value CDATA #REQUIRED +> + +<!ELEMENT unknown-handler-stack (unknown-handler-ref*)> +<!ELEMENT unknown-handler-ref (#PCDATA)> +<!ATTLIST unknown-handler-ref + name CDATA #REQUIRED +> + +<!-- END SNIPPET: strutsDtd --> + diff --git a/src/test/java/com/intellij/struts2/dom/inspection/StrutsDtdValidatorTest.java b/src/test/java/com/intellij/struts2/dom/inspection/StrutsDtdValidatorTest.java index 8b542f8..b872b9c 100644 --- a/src/test/java/com/intellij/struts2/dom/inspection/StrutsDtdValidatorTest.java +++ b/src/test/java/com/intellij/struts2/dom/inspection/StrutsDtdValidatorTest.java @@ -62,6 +62,54 @@ public class StrutsDtdValidatorTest extends BasePlatformTestCase { assertEquals(StrutsDtdValidator.Result.HTTP_INSTEAD_OF_HTTPS, StrutsDtdValidator.validate(file)); } + public void testValidStruts65HttpsDtdReturnsOk() { + XmlFile file = (XmlFile) myFixture.configureByText("struts.xml", + """ + <?xml version="1.0" encoding="UTF-8" ?> + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 6.5//EN" + "https://struts.apache.org/dtds/struts-6.5.dtd"> + <struts/> + """); + assertEquals(StrutsDtdValidator.Result.OK, StrutsDtdValidator.validate(file)); + } + + public void testValidStruts75HttpsDtdReturnsOk() { + XmlFile file = (XmlFile) myFixture.configureByText("struts.xml", + """ + <?xml version="1.0" encoding="UTF-8" ?> + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 7.5//EN" + "https://struts.apache.org/dtds/struts-7.5.dtd"> + <struts/> + """); + assertEquals(StrutsDtdValidator.Result.OK, StrutsDtdValidator.validate(file)); + } + + public void testHttpInsteadOfHttpsForStruts65ReturnsWarning() { + XmlFile file = (XmlFile) myFixture.configureByText("struts.xml", + """ + <?xml version="1.0" encoding="UTF-8" ?> + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 6.5//EN" + "http://struts.apache.org/dtds/struts-6.5.dtd"> + <struts/> + """); + assertEquals(StrutsDtdValidator.Result.HTTP_INSTEAD_OF_HTTPS, StrutsDtdValidator.validate(file)); + } + + public void testHttpInsteadOfHttpsForStruts75ReturnsWarning() { + XmlFile file = (XmlFile) myFixture.configureByText("struts.xml", + """ + <?xml version="1.0" encoding="UTF-8" ?> + <!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 7.5//EN" + "http://struts.apache.org/dtds/struts-7.5.dtd"> + <struts/> + """); + assertEquals(StrutsDtdValidator.Result.HTTP_INSTEAD_OF_HTTPS, StrutsDtdValidator.validate(file)); + } + public void testHttpInsteadOfHttpsForStrutsLikeDtdReturnsWarning() { XmlFile file = (XmlFile) myFixture.configureByText("struts.xml", """
