Author: sdumitriu
Date: 2008-02-19 17:05:14 +0100 (Tue, 19 Feb 2008)
New Revision: 7850
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiAction.java
xwiki-platform/core/trunk/xwiki-core/src/main/resources/ApplicationResources.properties
Log:
XWIKI-2091: Malformed URLs should not throw exceptions, but report an error
XWIKI-1929: URLs containing ":" generate exceptions
Fixed.
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
2008-02-19 15:56:30 UTC (rev 7849)
+++ xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
2008-02-19 16:05:14 UTC (rev 7850)
@@ -1131,7 +1131,15 @@
public XWikiDocument getDocument(String fullname, XWikiContext context)
throws XWikiException
{
XWikiDocument doc = new XWikiDocument();
- doc.setFullName(fullname, context);
+ try {
+ doc.setFullName(fullname, context);
+ } catch (Exception ex) {
+ // The name isn't good. The most frequent cause for this is a kind
of spam attempt which
+ // gives some ugly URLs.
+ throw new XWikiException(XWikiException.MODULE_XWIKI_APP,
+ XWikiException.ERROR_XWIKI_APP_URL_EXCEPTION,
+ "Invalid document name: " + fullname);
+ }
return getDocument(doc, context);
}
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiAction.java
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiAction.java
2008-02-19 15:56:30 UTC (rev 7849)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiAction.java
2008-02-19 16:05:14 UTC (rev 7850)
@@ -236,6 +236,15 @@
Utils.parseTemplate(context.getWiki().Param("xwiki.attachment_exception",
"attachmentdoesnotexist"), context);
return null;
+ } else if (xex.getCode() ==
XWikiException.ERROR_XWIKI_APP_URL_EXCEPTION) {
+ vcontext.put("message", context.getMessageTool().get(
+ "platform.core.invalidUrl"));
+ xwiki.setPhonyDocument(xwiki.getDefaultWeb(context) +
"."
+ + xwiki.getDefaultPage(context), context,
vcontext);
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ Utils.parseTemplate(context.getWiki().Param(
+ "xwiki.invalid_url_exception", "error"), context);
+ return null;
}
vcontext.put("exp", e);
if (LOG.isWarnEnabled()) {
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/resources/ApplicationResources.properties
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/resources/ApplicationResources.properties
2008-02-19 15:56:30 UTC (rev 7849)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/resources/ApplicationResources.properties
2008-02-19 16:05:14 UTC (rev 7850)
@@ -933,4 +933,5 @@
platform.core.errorMessageType=Error
platform.core.noticeMessageType=Notice
-platform.core.warningMessageType=Warning
\ No newline at end of file
+platform.core.warningMessageType=Warning
+platform.core.invalidUrl=This is not a valid URL
\ No newline at end of file
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications