git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@530664 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -94,7 +94,9 @@ not nested into a section will be added to the "Main" section.</p> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td valign="top">name</td> | <td valign="top">name</td> | ||||
| <td valign="top">the name of the attribute.</td> | |||||
| <td valign="top">the name of the attribute, <br> | |||||
| must match the regexp <tt>[A-Za-z0-9][A-Za-z0-9-_]*</tt>. | |||||
| </td> | |||||
| <td valign="top" align="center">Yes</td> | <td valign="top" align="center">Yes</td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| @@ -227,6 +227,24 @@ | |||||
| </manifest> | </manifest> | ||||
| </target> | </target> | ||||
| <target name="testIllegalNameBegin"> | |||||
| <manifest file="mftestillegalnamebegin.mf"> | |||||
| <attribute name="-name" value="value"/> | |||||
| </manifest> | |||||
| </target> | |||||
| <target name="testIllegalName2"> | |||||
| <manifest file="mftestillegalnamebegin.mf"> | |||||
| <attribute name="has.point" value="value"/> | |||||
| </manifest> | |||||
| </target> | |||||
| <target name="testIllegalName3"> | |||||
| <manifest file="mftestillegalnamebegin.mf"> | |||||
| <attribute name="has*star" value="value"/> | |||||
| </manifest> | |||||
| </target> | |||||
| <target name="clean"> | <target name="clean"> | ||||
| <delete> | <delete> | ||||
| <fileset dir="." includes="mftest*"/> | <fileset dir="." includes="mftest*"/> | ||||
| @@ -139,20 +139,20 @@ public class ManifestTask extends Task { | |||||
| * check each character. | * check each character. | ||||
| * | * | ||||
| * @param attribute The attribute to check | * @param attribute The attribute to check | ||||
| * @throws ManifestException if the check fails | |||||
| * @throws BuildException if the check fails | |||||
| */ | */ | ||||
| private void checkAttribute(Manifest.Attribute attribute) throws ManifestException { | |||||
| private void checkAttribute(Manifest.Attribute attribute) throws BuildException { | |||||
| String name = attribute.getName(); | String name = attribute.getName(); | ||||
| char ch = name.charAt(0); | char ch = name.charAt(0); | ||||
| if (ch == '-' || ch == '_') { | if (ch == '-' || ch == '_') { | ||||
| throw new ManifestException("Manifest attribute names must not contain '" + ch + "'"); | |||||
| throw new BuildException("Manifest attribute names must not contain '" + ch + "' at the begin."); | |||||
| } | } | ||||
| for (int i = 0; i < name.length(); i++) { | for (int i = 0; i < name.length(); i++) { | ||||
| ch = name.charAt(i); | ch = name.charAt(i); | ||||
| if (VALID_ATTRIBUTE_CHARS.indexOf(ch) < 0) { | if (VALID_ATTRIBUTE_CHARS.indexOf(ch) < 0) { | ||||
| throw new ManifestException("Manifest attribute names must not contain '" + ch + "'"); | |||||
| throw new BuildException("Manifest attribute names must not contain '" + ch + "'"); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -331,17 +331,27 @@ public class ManifestTest extends BuildFileTest { | |||||
| public void testFrom() { | public void testFrom() { | ||||
| expectLogContaining("testFrom", Manifest.ERROR_FROM_FORBIDDEN); | expectLogContaining("testFrom", Manifest.ERROR_FROM_FORBIDDEN); | ||||
| } | } | ||||
| public void testIllegalName() { | public void testIllegalName() { | ||||
| //expectBuildException("testIllegalName", "Attribute name is not valid according to the specification."); | |||||
| expectBuildException("testIllegalName", "Manifest attribute names must not contain ' '"); | |||||
| } | } | ||||
| public void testIllegalNameInSection() { | public void testIllegalNameInSection() { | ||||
| //expectBuildException("testIllegalNameInSection", "Attribute name is not valid according to the specification."); | |||||
| expectBuildException("testIllegalNameInSection", "Manifest attribute names must not contain ' '"); | |||||
| } | } | ||||
| public void testIllegalNameBegin() { | |||||
| expectBuildException("testIllegalNameInSection", "Manifest attribute names must not contain '-' at the begin."); | |||||
| } | |||||
| public void testIllegalName2() { | |||||
| expectBuildException("testIllegalName", "Manifest attribute names must not contain '.'"); | |||||
| } | |||||
| public void testIllegalName3() { | |||||
| expectBuildException("testIllegalName", "Manifest attribute names must not contain '*'"); | |||||
| } | |||||
| /** | /** | ||||
| * Reads mftest.mf. | * Reads mftest.mf. | ||||
| */ | */ | ||||