← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1424: Minor simplification of validation with smarter regex. Thanks Jason.

 

------------------------------------------------------------
revno: 1424
committer: Bob Jolliffe <bobj@bobj-laptop>
branch nick: trunk
timestamp: Fri 2010-02-12 12:37:39 +0000
message:
  Minor simplification of validation with smarter regex.  Thanks Jason.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java	2010-02-12 12:22:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java	2010-02-12 12:37:39 +0000
@@ -122,11 +122,13 @@
         }
 
             if ( conceptName != null || !conceptName.isEmpty()) {
-            // No funny characters please.  max length 10.
-            Pattern conceptNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z_]+$");
+            
+            // This string will be used as an XML attribute name.  So:
+            // Start with a letter. No funny characters please.  max length 10.
+            Pattern conceptNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z_]{1,10}$");
             Matcher matcher = conceptNamePattern.matcher(conceptName);
 
-            if (conceptName.length()>10 || !matcher.matches())
+            if (!matcher.matches())
             {
                 message = i18n.getString( "illegal_conceptName" );