On May 17, 2008, at 3:44 AM, sdumitriu (SVN) wrote:
Author: sdumitriu
Date: 2008-05-17 03:44:04 +0200 (Sat, 17 May 2008)
New Revision: 9842
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
doc/rcs/XWikiRCSArchive.java
Log:
XWIKI-2379: Import fails on document archive field
Fixed, I hope
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/
xwiki/doc/rcs/XWikiRCSArchive.java
===================================================================
--- xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
doc/rcs/XWikiRCSArchive.java 2008-05-17 00:59:08 UTC (rev 9841)
+++ xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
doc/rcs/XWikiRCSArchive.java 2008-05-17 01:44:04 UTC (rev 9842)
@@ -153,7 +153,7 @@
// empty author is error in jrcs
if (user == null || "".equals(user)) {
super.setAuthor(sauthorIfEmpty);
- } else {
+ } else {
byte[] enc = URLCodec.encodeUrl(safeAuthorChars,
user.getBytes());
String senc = new String(enc).replace('%', '_');
super.setAuthor(senc);
@@ -170,12 +170,17 @@
result = result.replace('_', '%');
try {
byte[] dec =
URLCodec.decodeUrl(result.getBytes());
- String sdec = new String(dec);
- return sdec;
+ result = new String(dec);
} catch (DecoderException e) {
- throw new Error(e);
+ // Probably the archive was created before
introducing this encoding (1.2M1/M2).
+ result = super.getAuthor();
+ if (!result.matches("^(\\w|\\d|\\.)++$")) {
+ // It's safer to use an empty author than
to use an invalid value.
+ result = "";
shouldn't we log a warning here?
[snip]
Thanks
-Vincent