commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TEXT-74) StrSubstitutor: Ability to turn off substitution in values
Date Sun, 08 Oct 2017 10:25:00 GMT

    [ https://issues.apache.org/jira/browse/TEXT-74?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16196052#comment-16196052
] 

ASF GitHub Bot commented on TEXT-74:
------------------------------------

Github user coveralls commented on the issue:

    https://github.com/apache/commons-text/pull/68
  
    
    [![Coverage Status](https://coveralls.io/builds/13620504/badge)](https://coveralls.io/builds/13620504)
    
    Coverage increased (+0.003%) to 98.239% when pulling **5bd02a5f8ec870c27bc8995e7ada90997c142144
on sermojohn:TEXT-74** into **317ae8452bb616d4dcbdd9b9d561d8daf2bb5260 on apache:master**.



> StrSubstitutor: Ability to turn off substitution in values
> ----------------------------------------------------------
>
>                 Key: TEXT-74
>                 URL: https://issues.apache.org/jira/browse/TEXT-74
>             Project: Commons Text
>          Issue Type: Improvement
>            Reporter: Arend v. Reinersdorff
>            Priority: Minor
>              Labels: features
>             Fix For: 1.x
>
>
> StrSubstitutor replaces variables in values. And currently there's no way to turn this
off.
> Why turn it off: I want to replace some variables in a simple template. Some of the replacement
values are arbitrary user input.
> At the moment I escape all dollar signs in the replacement values with "$$". This is
annoying. Especially as I use one template with variables as a value for another variable.
Here I have to escape twice.
> Here's some example code. At the moment it prints:
> {code}
> Hello Hamburg from Hamburg
> {code}
> The commented line is my suggestion for this feature. If it works, it should print:
> {code}
> Hello ${city} from Hamburg
> {code}
> {code}
> // untrusted user input
> String userInputName = "${city}";
> String userInputCity = "Hamburg";
> Map<String, String> valueMap = new HashMap<>();
> valueMap.put("name", userInputName);
> valueMap.put("city", userInputCity);
> String source = "Hello ${name} from ${city}";
> StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap);
> // strSubstitutor.setEnableSubstitutionInValues(false);
> System.out.println(strSubstitutor.replace(source));
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message