Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 92E4C200CC4 for ; Thu, 13 Jul 2017 21:39:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8FA1B16CBE1; Thu, 13 Jul 2017 19:39:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D614E16CBE0 for ; Thu, 13 Jul 2017 21:39:13 +0200 (CEST) Received: (qmail 98379 invoked by uid 500); 13 Jul 2017 19:39:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 98368 invoked by uid 99); 13 Jul 2017 19:39:13 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jul 2017 19:39:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 8206DC06E7 for ; Thu, 13 Jul 2017 19:39:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id rNUgAJM__e0I for ; Thu, 13 Jul 2017 19:39:11 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id C26FE5FCD2 for ; Thu, 13 Jul 2017 19:39:10 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 471A7E08B7 for ; Thu, 13 Jul 2017 19:39:10 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id D0B2B2475A for ; Thu, 13 Jul 2017 19:39:01 +0000 (UTC) Date: Thu, 13 Jul 2017 19:39:01 +0000 (UTC) From: "Arend v. Reinersdorff (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (TEXT-74) StrSubstitutor: Ability to turn off substitution in values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 13 Jul 2017 19:39:14 -0000 [ https://issues.apache.org/jira/browse/TEXT-74?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Arend v. Reinersdorff updated TEXT-74: -------------------------------------- Description: In StrSubstitutor variable replacement works in a recursive way. 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 replacemnt 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 world {code} The commented line is my suggestion for this feature. If it works, it should print: {code} Hello ${key2} {code} {code} Map valueMap = new HashMap<>(); valueMap.put("key", "${key2}"); valueMap.put("key2", "world"); String source = "Hello ${key}"; StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap); // strSubstitutor.setEnableSubstitutionInValues(false); System.out.println(strSubstitutor.replace(source)); {code} was: In StrSubstitutor variable replacement works in a recursive way. 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 replacemnt 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 world {code} The commented line is my suggestion for this feature. If it works, it should print: {code} Hello ${key2} {code} {code} Map valueMap = new HashMap<>(); valueMap.put("key", "$${key2}"); valueMap.put("key2", "world"); String source = "Hello ${key}"; StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap); // strSubstitutor.setEnableSubstitutionInValues(false); System.out.println(strSubstitutor.replace(source)); {code} > 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 > > > In StrSubstitutor variable replacement works in a recursive way. 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 replacemnt 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 world > {code} > The commented line is my suggestion for this feature. If it works, it should print: > {code} > Hello ${key2} > {code} > {code} > Map valueMap = new HashMap<>(); > valueMap.put("key", "${key2}"); > valueMap.put("key2", "world"); > String source = "Hello ${key}"; > 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)