You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by "jiraposter@reviews.apache.org (Commented) (JIRA)" <ji...@apache.org> on 2011/10/19 02:25:11 UTC

[jira] [Commented] (OOZIE-580) use xml element to handle string escape when configure evaluator

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

jiraposter@reviews.apache.org commented on OOZIE-580:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/2427/
-----------------------------------------------------------

Review request for oozie.


Summary
-------

try {
        String valueElem = "<value>"+value+"</value>";
        XmlUtils.parseXml(valueElem);
}
catch (JDOMException ex) {
        // It should not happen, so escape the characters for xml
        value = XmlUtils.escapeCharsForXML(value);
}

With above check, for element CDATA can be avoided for escaping, EX:

For these two elements, first one has to convert because of '&', however second one can be avoided.
 
    <property>
      <name>test.ampsign</name>
      <value>http://app1.soln-stage.nova.cp.vip.ne1.yahoo.com/nova-webservices?urlSigner=signUrl&namespace=nova.proxy</value>
    </property>
    <property>
      <name>test.cdata</name>
      <value><![CDATA[?redirect=http%3A%2F%2Fapp1.soln-stage.nova.cp.vip.ne1.yahoo.com%3A4080%2Fnova-webservices%2Fv1%2FurlSigner%2FsignUrl&amp;namespace=nova.proxy&amp;keyDBHash=Vsy6n_C7K6NG0z4R2eBlKg--]]></value>
    </property>


*** & has to convert to &amp; ***
*** <![CDATA[]] does not need to convert. ***

    <property>
      <name>test.ampsign</name>
      <value>http://app1.soln-stage.nova.cp.vip.ne1.yahoo.com/nova-webservices?urlSigner=signUrl&amp;namespace=nova.proxy</value>
    </property>
    <property>
      <name>test.cdata</name>
      <value><![CDATA[?redirect=http%3A%2F%2Fapp1.soln-stage.nova.cp.vip.ne1.yahoo.com%3A4080%2Fnova-webservices%2Fv1%2FurlSigner%2FsignUrl&namespace=nova.proxy&keyDBHash=Vsy6n_C7K6NG0z4R2eBlKg--]]></value>
    </property>


This addresses bug OOZIE-580.
    https://issues.apache.org/jira/browse/OOZIE-580


Diffs
-----

  /trunk/core/src/main/java/org/apache/oozie/command/wf/ActionStartXCommand.java 1185461 
  /trunk/core/src/test/java/org/apache/oozie/command/wf/TestActionStartXCommand.java 1185461 
  /trunk/core/src/main/java/org/apache/oozie/DagELFunctions.java 1185461 
  /trunk/release-log.txt 1185461 

Diff: https://reviews.apache.org/r/2427/diff


Testing
-------


Thanks,

Angelo K.


                
> use xml element to handle string escape when configure evaluator
> ----------------------------------------------------------------
>
>                 Key: OOZIE-580
>                 URL: https://issues.apache.org/jira/browse/OOZIE-580
>             Project: Oozie
>          Issue Type: Improvement
>            Reporter: Angelo K. Huang
>            Assignee: Angelo K. Huang
>
> Instead of using string value to do escape, xml element is able to do it and also avoid escaping legit character at XML element, such as <![CDATA[]]>.
> public static void configureEvaluator(ELEvaluator evaluator, WorkflowJobBean workflow, WorkflowActionBean action) {
>         evaluator.setVariable(WORKFLOW, workflow);
>         evaluator.setVariable(ACTION, action);
>         for (Map.Entry<String, String> entry : workflow.getWorkflowInstance().getConf()) {
>             if (ParamChecker.isValidIdentifier(entry.getKey())) {
>                 String value = entry.getValue().trim();
>                 // escape the characters for xml
>                 value = XmlUtils.escapeCharsForXML(value);
>                 evaluator.setVariable(entry.getKey().trim(), value);
>             }
>         }
>         try {
>             evaluator.setVariable(ACTION_PROTO_CONF,
>                                   new XConfiguration(new StringReader(workflow.getProtoActionConf())));
>         }
>         catch (IOException ex) {
>             throw new RuntimeException("It should not happen", ex);
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira