You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "munene kiruja (JIRA)" <ji...@apache.org> on 2015/12/18 19:57:46 UTC
[jira] [Comment Edited] (FELIX-5145) FileInstall writes .config
files back with backslashes escaping spaces in config values
[ https://issues.apache.org/jira/browse/FELIX-5145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15064464#comment-15064464 ]
munene kiruja edited comment on FELIX-5145 at 12/18/15 6:56 PM:
----------------------------------------------------------------
the writeQuoted static function in package org.apache.felix.cm.file.ConfigurationHandler.java can be changed to ignore escaping spaces as follows.
line 764, lines 789-795, 797
{code}
private static void writeQuoted( Writer out, String simple ) throws IOException
{
if ( simple == null || simple.length() == 0 )
{
return;
}
char c = 0;
int len = simple.length();
for ( int i = 0; i < len; i++ )
{
c = simple.charAt( i );
switch ( c )
{
case '\\':
case TOKEN_VAL_CLOS:
// case ' ':
case TOKEN_EQ:
out.write( '\\' );
out.write( c );
break;
// well known escapes
case '\b':
out.write( "\\b" );
break;
case '\t':
out.write( "\\t" );
break;
case '\n':
out.write( "\\n" );
break;
case '\f':
out.write( "\\f" );
break;
case '\r':
out.write( "\\r" );
break;
// other escaping
default:
// if ( c < ' ' )
// {
// String t = "000" + Integer.toHexString( c );
// out.write( "\\u" + t.substring( t.length() - 4 ) );
// }
// else
// {
out.write( c );
// }
}
}
}
{code}
was (Author: munene.kiruja):
the writeQuoted static function in package org.apache.felix.cm.file can be changed to ignore escaping spaces as follows.
line 764, lines 789-795, 797
{code}
private static void writeQuoted( Writer out, String simple ) throws IOException
{
if ( simple == null || simple.length() == 0 )
{
return;
}
char c = 0;
int len = simple.length();
for ( int i = 0; i < len; i++ )
{
c = simple.charAt( i );
switch ( c )
{
case '\\':
case TOKEN_VAL_CLOS:
// case ' ':
case TOKEN_EQ:
out.write( '\\' );
out.write( c );
break;
// well known escapes
case '\b':
out.write( "\\b" );
break;
case '\t':
out.write( "\\t" );
break;
case '\n':
out.write( "\\n" );
break;
case '\f':
out.write( "\\f" );
break;
case '\r':
out.write( "\\r" );
break;
// other escaping
default:
// if ( c < ' ' )
// {
// String t = "000" + Integer.toHexString( c );
// out.write( "\\u" + t.substring( t.length() - 4 ) );
// }
// else
// {
out.write( c );
// }
}
}
}
{code}
> FileInstall writes .config files back with backslashes escaping spaces in config values
> ---------------------------------------------------------------------------------------
>
> Key: FELIX-5145
> URL: https://issues.apache.org/jira/browse/FELIX-5145
> Project: Felix
> Issue Type: Bug
> Components: Configuration Admin, File Install
> Affects Versions: fileinstall-3.5.0
> Reporter: munene kiruja
> Fix For: fileinstall-3.5.2
>
>
> Fileinstall 3.5.0 added handling of .config file with an expanded syntax for configuration files allowing proper handling of arrays, etc. A great feature.
> There is one thing that appears to be handled improperly though - if the values in the key/value pairs have spaces in them, the files are written back with backslash escapes for the spaces.
> What is the justification for that?
> The effect is that the file is different from the original - which is quite a pain for automated installation with files generated from templates. The fake changes become a maintenance nightmare.
> It appears that escaping of spaces can be harmlessly removed, and perhaps should not be a part of the feature...
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)