9 Replies Latest reply on Nov 7, 2017 11:31 AM by platapapin

    Escaping double quotes in WildFly CLI system parameter configuration values

    platapapin

      I'm converting some JBoss AS CLI scripts to WildFly 11.0.0 CR1, and I'm having a problem with system property values that contain double quotes.  In the CLI command, I'm escaping the double quotes with a backslash, i.e. \". What is being written to the <system-properties><property value= "" />entry in the XML configuration file (e.g. standalone.xml) is &quot;, which is obviously the XML escape sequence for the double quote character. However, when the system parameter is actually set in the JVM runtime by the AS at startup, the XML escape encoding is not removed, i.e. what is set in the system property is literally &quot;, not the single quote character ".

       

      Can someone shed some light on how WildFly handles  escaped special characters in <system-properties> elements? Could this possibly be a bug?

        • 1. Re: Escaping double quotes in WildFly CLI system parameter configuration values
          mchoma

          I can't reproduce based on your description. Can you reproduce on WildFly 11 Final?

           

          Can you describe reproducer steps in detail?

          • 2. Re: Escaping double quotes in WildFly CLI system parameter configuration values
            platapapin

            I can reproduce this on WildFly 11 Final.

             

            I am attempting to set a system property with the following CLI command:

             

            /system-property=com.example.type.list:add(value="[{\"code\":\"\",\"description\":\"\"},{\"code\":\"20R\",\"description\":\"20R\"},{\"code\":\"28R\",\"description\":\"28R\"},{\"code\":\"35R\",\"description\":\"35R\"},{\"code\":\"40R\",\"description\":\"40R\"},{\"code\":\"45R\",\"description\":\"45R\"},{\"code\":\"48R\",\"description\":\"48R\"},{\"code\":\"53R\",\"description\":\"53R\"},{\"code\":\"20V\",\"description\":\"20V\"},{\"code\":\"28V\",\"description\":\"28V\"},{\"code\":\"35V\",\"description\":\"35V\"},{\"code\":\"40V\",\"description\":\"40V\"},{\"code\":\"45V\",\"description\":\"45V\"},{\"code\":\"48V\",\"description\":\"48V\"},{\"code\":\"53V\",\"description\":\"53V\"},{\"code\":\"20000\",\"description\":\"20000\"},{\"code\":\"28000\",\"description\":\"28000\"},{\"code\":\"40000\",\"description\":\"40000\"},{\"code\":\"45000\",\"description\":\"45000\"},{\"code\":\"48000\",\"description\":\"48000\"},{\"code\":\"53000\",\"description\":\"53000\"}]")

             

            This is the string that is written to the standalone.xml file, and subsequently set in the JVM system property com.example.type.list:

             

            <property name="com.example.type.list" value="[{&quot;code&quot;:&quot;&quot;,&quot;description&quot;:&quot;&quot;},{&quot;code&quot;:&quot;20R&quot;,&quot;description&quot;:&quot;20R&quot;},{&quot;code&quot;:&quot;28R&quot;,&quot;description&quot;:&quot;28R&quot;},{&quot;code&quot;:&quot;35R&quot;,&quot;description&quot;:&quot;35R&quot;},{&quot;code&quot;:&quot;40R&quot;,&quot;description&quot;:&quot;40R&quot;},{&quot;code&quot;:&quot;45R&quot;,&quot;description&quot;:&quot;45R&quot;},{&quot;code&quot;:&quot;48R&quot;,&quot;description&quot;:&quot;48R&quot;},{&quot;code&quot;:&quot;53R&quot;,&quot;description&quot;:&quot;53R&quot;},{&quot;code&quot;:&quot;20V&quot;,&quot;description&quot;:&quot;20V&quot;},{&quot;code&quot;:&quot;28V&quot;,&quot;description&quot;:&quot;28V&quot;},{&quot;code&quot;:&quot;35V&quot;,&quot;description&quot;:&quot;35V&quot;},{&quot;code&quot;:&quot;40V&quot;,&quot;description&quot;:&quot;40V&quot;},{&quot;code&quot;:&quot;45V&quot;,&quot;description&quot;:&quot;45V&quot;},{&quot;code&quot;:&quot;48V&quot;,&quot;description&quot;:&quot;48V&quot;},{&quot;code&quot;:&quot;53V&quot;,&quot;description&quot;:&quot;53V&quot;},{&quot;code&quot;:&quot;20000&quot;,&quot;description&quot;:&quot;20000&quot;},{&quot;code&quot;:&quot;28000&quot;,&quot;description&quot;:&quot;28000&quot;},{&quot;code&quot;:&quot;40000&quot;,&quot;description&quot;:&quot;40000&quot;},{&quot;code&quot;:&quot;45000&quot;,&quot;description&quot;:&quot;45000&quot;},{&quot;code&quot;:&quot;48000&quot;,&quot;description&quot;:&quot;48000&quot;},{&quot;code&quot;:&quot;53000&quot;,&quot;description&quot;:&quot;53000&quot;}]"/>

             

            Let me know what you think.

            • 3. Re: Escaping double quotes in WildFly CLI system parameter configuration values
              mchoma

              And how do you "consume" system property value? I have tried jsp scriptlet <%=System.getProperty("com.example.type.list")%> and it renders ok.

               

              Or what is your problem?

              • 4. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                platapapin

                We retrieve the property the same way, i.e System.getProperty("com.example.type.list"),  but from within a stateless session bean, not a JSP.

                 

                Since the system property contains HTML compatible escape sequences, I suspect that your browser is un-escaping the content when rendering the JSP, so you see the un-escaped version. In our case we are reading the property value (which is a JSON string) and are expecting to find actual double quote characters, not the escape sequence.

                 

                Our problem is that the WildFly CLI is converting the double quotes to escape sequences in order to write them to the server configuration file, but not un-escaping them when it puts the values in the JVM runtime system properties. So we effectively cannot put double quotes in <system-property> configuration elements.

                 

                Maybe this is the intended behavior? If so, should there be an optional parameter in the <system-properties> element to tell it to un-escape XML before setting the system property?

                • 5. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                  mchoma

                  It is also correctly in html source code - that is how it comes from server. Also when I use wget or curl. Also I see it properly in jconsole.

                  • 6. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                    platapapin

                    Can you please post the the CLI command you are using to set the property with?

                    • 7. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                      mchoma

                      I used your CLI command.

                      • 8. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                        jaikiran

                        Just like Martin, I can't reproduce this either. I'm on WildFly 11.0.0.Final with Java 8. I added the exact same system property plus a few others just to make sure they are stored and parsed correctly. I then just used System.getProperty to print it out in one of the server side classes. All works fine and the value correctly contains the double quote character instead of the escape literal.

                         

                        In our case we are reading the property value (which is a JSON string) and are expecting to find actual double quote characters, not the escape sequence.

                        Can you paste the relevant code? Furthermore, please include few other details like what operating system and Java vendor and version (java -version should give you that) you are using and how exactly are you finding that the escape sequence is being returned to you by a call to System.getProperty?

                        • 9. Re: Escaping double quotes in WildFly CLI system parameter configuration values
                          platapapin

                          After deleting and recreating the system-property entry via the CLI and running the test again, we found that the problem does not in fact occur on WildFly 11 final. The value read from the system property contains properly un-escaped double quotes.

                           

                          We will continue to test and post additional information if we can manage create the problem again on WildFly 11, but for now I think the issue is resolved.