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

Key: WW-1205
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Rene Gielen
Reporter: Robbin Fan
Votes: 1
Watchers: 0
Operations

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

RegexFieldValidator cannot process white space string correctly

Created: 22/Feb/06 08:57 AM   Updated: 18/Jul/07 05:17 AM
Component/s: None
Affects Version/s: 2.2.1
Fix Version/s: 2.2.2

Issue Links:
Related
This issue relates to:
XW-443 Validator parameters and message hand... Minor Resolved
 


 Description  « Hide
see such code snippet:
<field-validator type="regex">
         <param name="expression">
                  <![CDATA[([aAbBcCdD][123][eEfFgG][456])]]>
          </param>
</field-validator>

RegexFieldValidator read expression string including embracing white space and cannot process expression correctly. I must trim embracing white space and write <param> entity in one line, then RegexFieldValidator will work fine.

<param name="expression"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]></param>

 All   Comments   Change History      Sort Order:
Robbin Fan - [22/Feb/06 09:06 AM ]
See com.opensymphony.xwork.validator.ValidatorFileParser line 147:

String paramValue = paramElement.getFirstChild().getNodeValue();

We could and trim() method,
 String paramValue = paramElement.getFirstChild().getNodeValue().trim();

to trim embracing white space around expression.

Rene Gielen - [22/Feb/06 11:21 AM ]
Makes perfect sense to me. Apllied a NPE aware trim in my local source copy, tests work fine.

Others: Any objections adding this to the codebase?

Quake Wang - [23/Feb/06 12:02 AM ]
We got same issue before, please note that adding trim only resolves the multiple line TextNode issue, CDATA is still an issue. Suggest to reference springframework's xml parser method:

protected String getTextValue(Element ele, String beanName) {
StringBuffer value = new StringBuffer();
NodeList nl = ele.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node item = nl.item(i);
if (item instanceof org.w3c.dom.CharacterData) {
if (!(item instanceof Comment)) {
value.append(item.getNodeValue());
}
}
else {
throw new BeanDefinitionStoreException(
this.resource, beanName,
"<value> element is just allowed to have text and comment nodes, not: " + item.getClass().getName());
}
}
return value.toString();
}

Alexandru Popescu - [25/Feb/06 06:33 PM ]
Makes sense to me. Rene, I think you can safely apply the fix.

./alex
--
.w( the_mindstorm )p.

Rene Gielen - [26/Feb/06 07:33 AM ]
Taking Quake's comment into account, I created a textvalue processing method based on the latest version of the described method in Spring (in DomUtils) , which is also responsible for trimming. Added testcase too..

We should have a look into our configuration processing, the said method could be valuable in other places too. Basically, it provides much better handling for character data nodes, ignoring xml comments.