You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Phil Cornelius (JIRA)" <de...@velocity.apache.org> on 2007/04/03 15:57:32 UTC

[jira] Created: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Patch to add escaping for property values and property keys in java properties files.
-------------------------------------------------------------------------------------

                 Key: VELTOOLS-81
                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
             Project: Velocity Tools
          Issue Type: Improvement
          Components: GenericTools
    Affects Versions: 1.3
            Reporter: Phil Cornelius
            Priority: Minor


Special escaping is required when writing keys and values into java properties files.

I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.

This is useful for example when trying to templatize an install path, say.

Suppose I have a velocity variable available at runtime $INSTALL_PATH

I could templatize the following properties thus.
----before
#Policy Director properties file
#Wed Mar 28 16:26:19 BST 2007
mgmt_domain=Default
config_type=standalone
tcd_enabled=false
pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
--- templatized
#Policy Director properties file
#Wed Mar 28 16:26:19 BST 2007
mgmt_domain=Default
config_type=standalone
tcd_enabled=false
pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Phil Cornelius (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Cornelius updated VELTOOLS-81:
-----------------------------------

    Attachment: escape.patch

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Phil Cornelius (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487778 ] 

Phil Cornelius commented on VELTOOLS-81:
----------------------------------------

OK.. scrapped previous patch and started again with Harmony..

I also added the unit tests but I could not get them to run.. I checked out a fresh working set from the trunk and couldn't get the tests to run there either.. 

When the trunk test script is working I will revisit these tests to make sure they work.


> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch, escape_harmony.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487043 ] 

Nathan Bubna commented on VELTOOLS-81:
--------------------------------------

Actually, i just did a little investigating.   It looks like the OpenJDK version unfortunately  won't be acceptable either (see http://people.apache.org/~cliffs/3party.html#category-a for lists of licenses whose source we can and can't incorporate), since it is under GPLv2.  :(

Looks like it either has to be from Apache Harmony (whose SVN repo is baffling to me) or else written from scratch. In the latter case, it might be prudent to have you submit a CLA (http://www.apache.org/licenses/icla.txt).  I know, i don't think any sane person/corporation would really cause problems over this one little method, but i'm no lawyer and would rather be safe than sorry.  All this is to say, that the easiest path is probably to find the relevant code in Harmony.   I might take a look for it at some point, if you don't get to it.   This would be a useful patch to have, and i do appreciate it!

It's a shame Sun didn't just make the method public or protected in the first place...

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486374 ] 

Nathan Bubna commented on VELTOOLS-81:
--------------------------------------

So, you just copied the saveConvert() method out of the JDK source?  What version and what vendor?   Unless this is copied from Apache Harmony (or maybe OpenJDK?), i don't think we can accept the code due to license issues.

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487053 ] 

Nathan Bubna commented on VELTOOLS-81:
--------------------------------------

I found the Properties implementation for Harmony:

https://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java

If you don't mind, i'll leave it to you to take the relevant code and change the patch.

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Resolved: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna resolved VELTOOLS-81.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0
                   1.x
                   1.4

The test code ran perfect for me, as did everything else in the patch.  I've applied it to both the 1.x trunk and the 2.x branch.  Great work!  Thanks!

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>             Fix For: 1.4, 1.x, 2.0
>
>         Attachments: escape.patch, escape_harmony.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Phil Cornelius (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Cornelius updated VELTOOLS-81:
-----------------------------------

    Attachment: escape_harmony.patch

> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch, escape_harmony.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-81) Patch to add escaping for property values and property keys in java properties files.

Posted by "Phil Cornelius (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487029 ] 

Phil Cornelius commented on VELTOOLS-81:
----------------------------------------

Well that is the only way to ensure that the escaping is precisely the same..

The method is saveConvert from java.lang.Properties and is a private method.. I see your point about copying it directly.. but If I wrote it from scratch it would almost certainly be nearly identical..

I would check openjdk but the site is currently down for maintenance.. I am sure that it would probably be exactly the same code in which case there shouldn't be a problem including the code..


> Patch to add escaping for property values and property keys in java properties files.
> -------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-81
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-81
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 1.3
>            Reporter: Phil Cornelius
>            Priority: Minor
>         Attachments: escape.patch
>
>
> Special escaping is required when writing keys and values into java properties files.
> I have simply taken the escaping routines from java.util.Properties in the private method saveConvert(String, boolean) and have added two new methods to propertyKey and propertyValue used in the same way as the other escaping routines.
> This is useful for example when trying to templatize an install path, say.
> Suppose I have a velocity variable available at runtime $INSTALL_PATH
> I could templatize the following properties thus.
> ----before
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=C\:\\IBMTest1\\WebSphere\\AppServer/java/jre/PolicyDirector
> --- templatized
> #Policy Director properties file
> #Wed Mar 28 16:26:19 BST 2007
> mgmt_domain=Default
> config_type=standalone
> tcd_enabled=false
> pd-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector
> pdvar-home=$enc.propertyValue(${INSTALL_PATH})WebSphere\\AppServer/java/jre/PolicyDirector

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org