← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19178: Expression service, data set report service, using Matcher.quoteReplacement to quote dollar signs...

 

------------------------------------------------------------
revno: 19178
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-05-25 17:55:25 -0400
message:
  Expression service, data set report service, using Matcher.quoteReplacement to quote dollar signs to avoid matcher interpreting them as group references.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2015-04-24 13:45:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2015-05-25 21:55:25 +0000
@@ -607,7 +607,7 @@
                 throw new IllegalArgumentException( "Identifier does not reference a category option combo: " + coc );
             }
             
-            matcher.appendReplacement( sb, DataElementOperand.getPrettyName( dataElement, categoryOptionCombo ) );
+            matcher.appendReplacement( sb, Matcher.quoteReplacement( DataElementOperand.getPrettyName( dataElement, categoryOptionCombo ) ) );
         }
         
         expression = TextUtils.appendTail( matcher, sb );
@@ -630,7 +630,7 @@
                 throw new IllegalArgumentException( "Identifier does not reference a constant: " + co );
             }
             
-            matcher.appendReplacement( sb, constant.getDisplayName() );
+            matcher.appendReplacement( sb, Matcher.quoteReplacement( constant.getDisplayName() ) );
         }
 
         expression = TextUtils.appendTail( matcher, sb );
@@ -653,7 +653,7 @@
                 throw new IllegalArgumentException( "Identifier does not reference an organisation unit group: " + oug );
             }
             
-            matcher.appendReplacement( sb, group.getDisplayName() );
+            matcher.appendReplacement( sb, Matcher.quoteReplacement( group.getDisplayName() ) );
         }
 
         expression = TextUtils.appendTail( matcher, sb );
@@ -746,7 +746,7 @@
                 }
 
                 replace.deleteCharAt( replace.length() - 1 ).append( PAR_CLOSE );
-                matcher.appendReplacement( sb, replace.toString() );
+                matcher.appendReplacement( sb, Matcher.quoteReplacement( replace.toString() ) );
             }
         }
 
@@ -782,7 +782,7 @@
                 }
 
                 replace.deleteCharAt( replace.length() - 1 ).append( PAR_CLOSE );
-                matcher.appendReplacement( sb, replace.toString() );
+                matcher.appendReplacement( sb, Matcher.quoteReplacement( replace.toString() ) );
             }
         }
 
@@ -813,7 +813,7 @@
             
             String replacement = constant != null ? String.valueOf( constant.getValue() ) : NULL_REPLACEMENT; 
             
-            matcher.appendReplacement( sb, replacement );
+            matcher.appendReplacement( sb, Matcher.quoteReplacement( replacement ) );
         }
 
         expression = TextUtils.appendTail( matcher, sb );
@@ -907,7 +907,7 @@
 
             String replacement = value != null ? String.valueOf( value ) : NULL_REPLACEMENT;
             
-            matcher.appendReplacement( sb, replacement );
+            matcher.appendReplacement( sb, Matcher.quoteReplacement( replacement ) );
         }
         
         if ( SKIP_IF_ALL_VALUES_MISSING.equals( missingValueStrategy ) && matchCount > 0 && valueCount == 0 )

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2015-05-25 21:55:25 +0000
@@ -323,7 +323,7 @@
 
                 String value = "<span class=\"val\" data-de=\"" + dataElementId + "\" data-co=\"" + optionComboId + "\">" + format.formatValue( dataValue ) + "</span>";
                 
-                inputMatcher.appendReplacement( buffer, value );
+                inputMatcher.appendReplacement( buffer, Matcher.quoteReplacement( value ) );
             }
             else if ( dataElementTotalMatcher.find() && dataElementTotalMatcher.groupCount() > 0 )
             {
@@ -331,7 +331,7 @@
                 
                 Object dataValue = dataValues.get( dataElementId );
 
-                inputMatcher.appendReplacement( buffer, format.formatValue( dataValue ) );
+                inputMatcher.appendReplacement( buffer, Matcher.quoteReplacement( format.formatValue( dataValue ) ) );
             }
             else if ( indicatorMatcher.find() && indicatorMatcher.groupCount() > 0 )
             {
@@ -339,7 +339,7 @@
 
                 Object indicatorValue = indicatorValues.get( indicatorId );
 
-                inputMatcher.appendReplacement( buffer, format.formatValue( indicatorValue ) );
+                inputMatcher.appendReplacement( buffer, Matcher.quoteReplacement( format.formatValue( indicatorValue ) ) );
             }
         }