Author: trong.tran
Date: 2011-10-03 04:57:23 -0400 (Mon, 03 Oct 2011)
New Revision: 7595
Modified:
portal/branches/xss/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java
portal/branches/xss/component/portal/src/test/java/org/exoplatform/portal/config/TestEscape.java
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSearchForm.java
Log:
GTNPORTAL-2121 Exception when entering the single quotation mark for searching page in
Page Management portlet
Modified:
portal/branches/xss/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java
===================================================================
---
portal/branches/xss/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java 2011-10-03
05:48:02 UTC (rev 7594)
+++
portal/branches/xss/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java 2011-10-03
08:57:23 UTC (rev 7595)
@@ -184,6 +184,23 @@
*/
public static String queryEscape(String s)
{
- return s.replaceAll("[\\\\%_'\"]", "\\\\$0");
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < s.length(); i++)
+ {
+ char ch = s.charAt(i);
+ if (ch == '%' || ch == '"' || ch == '_' || ch ==
'\\')
+ {
+ buffer.append('\\').append(ch);
+ }
+ else if (ch == '\'')
+ {
+ buffer.append("''");
+ }
+ else
+ {
+ buffer.append(ch);
+ }
+ }
+ return buffer.toString();
}
}
Modified:
portal/branches/xss/component/portal/src/test/java/org/exoplatform/portal/config/TestEscape.java
===================================================================
---
portal/branches/xss/component/portal/src/test/java/org/exoplatform/portal/config/TestEscape.java 2011-10-03
05:48:02 UTC (rev 7594)
+++
portal/branches/xss/component/portal/src/test/java/org/exoplatform/portal/config/TestEscape.java 2011-10-03
08:57:23 UTC (rev 7595)
@@ -32,7 +32,7 @@
public void testQueryEscape()
{
assertEquals("\\%", Utils.queryEscape("%"));
- assertEquals("\\'", Utils.queryEscape("'"));
+ assertEquals("''", Utils.queryEscape("'"));
assertEquals("\\\"", Utils.queryEscape("\""));
assertEquals("\\_", Utils.queryEscape("_"));
assertEquals("\\\\", Utils.queryEscape("\\"));
Modified:
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
---
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-10-03
05:48:02 UTC (rev 7594)
+++
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-10-03
08:57:23 UTC (rev 7595)
@@ -152,9 +152,13 @@
String title = titleInput.getValue();
String ownerType = select.getValue();
if (title != null && title != "")
- query.setTitle(title);
+ {
+ query.setTitle(title.trim());
+ }
if (siteName != null && siteName != "")
- query.setOwnerId(siteName);
+ {
+ query.setOwnerId(siteName.trim());
+ }
query.setOwnerType(ownerType);
query.setName(null);
Modified:
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSearchForm.java
===================================================================
---
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSearchForm.java 2011-10-03
05:48:02 UTC (rev 7594)
+++
portal/branches/xss/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSearchForm.java 2011-10-03
08:57:23 UTC (rev 7595)
@@ -29,6 +29,7 @@
import org.exoplatform.webui.form.UIFormInputSet;
import org.exoplatform.webui.form.UIFormSelectBox;
import org.exoplatform.webui.form.UIFormStringInput;
+import org.exoplatform.webui.form.validator.ExpressionValidator;
import java.util.List;
@@ -50,7 +51,7 @@
{
UIFormInputSet uiQuickSearchSet = new UIFormInputSet(QUICK_SEARCH_SET);
uiQuickSearchSet.addUIFormInput(new UIFormStringInput("pageTitle",
"pageTitle", null));
- uiQuickSearchSet.addUIFormInput(new UIFormStringInput("siteName",
"siteName", null));
+ uiQuickSearchSet.addUIFormInput(new UIFormStringInput("siteName",
"siteName", null).addValidator(ExpressionValidator.class,
"[^\\'\"]*", "UISearchForm.msg.empty"));
uiQuickSearchSet.addUIFormInput(new UIFormSelectBox("searchOption", null,
null));
addChild(uiQuickSearchSet);
}