History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XW-412
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Rainer Hermanns
Reporter: Bill Lynch
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWork

Some XMLParsers parse the xwork config file differently, resulting in broken action results

Created: 09/Sep/06 08:02 PM   Updated: 16/Feb/07 07:10 AM
Component/s: Configuration
Affects Version/s: 1.2
Fix Version/s: 2.0, 1.2.2, 2.0.1, 2.1

File Attachments: 1. Java Source File XmlConfigurationProvider.java (30 kb)
2. File XmlConfigurationProvider.java.2 (30 kb)

Environment: SAP Netweaver platform
Issue Links:
Related
This issue relates to:
WW-1402 Action entry in xwork.xml not being r... Major Resolved
 

Flags: Patch


 Description  « Hide
I was running my webwork'd app through its paces on the SAP platform and I found a bug when action results contain the following type of result:

<result type="redirect">foo.jspa?fooID=${fooID}&amp;something=bar</result>

The XW code treats (and expects) one XML text node in the <result> body. Unfortuately, the default XML parser on the SAP platform treats this as 3 text nodes as it delimits on entities (&amp; is one). The problem is on this line of com.opensymphony.xwork.config.providers.XmlConfigurationProvider:

if ((resultElement.getChildNodes().getLength() == 1) && (resultElement.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE))

Problem is that resultElement.getChildNodes().getLength() will be > 1. So that branch is skipped and the location parameter on my result was never set. The fix is to check if the length is >= 1 then loop over all text nodes and append the location variable. I'll attach my fixed file -- I tested it and it works well.

NOTE: this probably affects all versions of XW so it'd be good to patch 2.x as well. I specifically did this work against 1.2.

 All   Comments   Change History      Sort Order:
Bill Lynch - [09/Sep/06 08:04 PM ]
Updated version, done against the 1.2 release of XW.

Specific fix is in buildResults(..) method, ~lines 436-462.

Bill Lynch - [09/Sep/06 08:09 PM ]
One more note, compiling xwork using the source distro was a PITA. I read on the mailing list that passing in -Dskip.ivy=true works, and it was what worked for me.

Don Brown - [09/Sep/06 08:27 PM ]
Fixed in the 1.2 branch and trunk. Thanks for the ticket and patch, Bill!

Bill Lynch - [10/Sep/06 01:56 PM ]
Whoops! I just noticed my index var was off in the code I submitted. In my loop I used "i" instead of "j". Attached is an updated file (note, this was done on the 1.2.1 codebase). Here's the code I'm talking about:

for (int j=0; j<resultElement.getChildNodes().getLength(); j++) {
                                if (resultElement.getChildNodes().item(j).getNodeType() == Node.TEXT_NODE) {
                                    String val = resultElement.getChildNodes().item(j).getNodeValue();
                                    if (val != null) {
                                        paramValue.append(val.trim());
                                    }
                                }
                            }

That's from com.opensymphony.xwork.config.providers.XmlConfigurationProvider.java ~line 446.

Bill Lynch - [10/Sep/06 01:57 PM ]
Note, the latest & greatest is XmlConfigurationProvider.java.2.

Don Brown - [10/Sep/06 08:58 PM ]
Yep, I already caught it and have fixed the 1.2 branch and trunk. :)

tm_jee - [30/Jan/07 09:15 AM ]
I think XmlHelper needs to be patched as well. See http://forums.opensymphony.com/thread.jspa?threadID=60774&tstart=0 for the patch and more info

Cheers

tm_jee - [30/Jan/07 10:18 AM ]
fixed in xwork-1.2 branch.

Sending src/java/com/opensymphony/xwork/config/providers/XmlHelper.java
Transmitting file data .
Committed revision 1318.

still need to fix it in xwork2 head, but I don't have the code for it. If someone have the code, please feel free to work on it. Tia

tm_jee - [30/Jan/07 10:28 AM ]
added more test case for this issue

Sending src/test/com/opensymphony/xwork/config/providers/XmlConfigurationProviderActionsTest.java
Sending src/test/com/opensymphony/xwork/config/providers/xwork-test-actions.xml
Transmitting file data ..
Committed revision 1319.

need to put this into xwork2 as well.

Rainer Hermanns - [16/Feb/07 06:45 AM ]
Toby, did you already port these fixes over to the 2.0 branch and trunk?

Rainer Hermanns - [16/Feb/07 07:10 AM ]
Fixed for all branches.
Applied the additional patches for XmlHelper to branch 2.0 and trunk