mirror of https://github.com/zlatinb/muwire
comments in shared files are encoded
parent
7d9ebb5b0b
commit
844bd8fd6e
|
@ -63,7 +63,7 @@ public class DataUtil {
|
||||||
((int)header[2] & 0xFF);
|
((int)header[2] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String readi18nString(byte [] encoded) {
|
public static String readi18nString(byte [] encoded) {
|
||||||
if (encoded.length < 2)
|
if (encoded.length < 2)
|
||||||
throw new IllegalArgumentException("encoding too short $encoded.length");
|
throw new IllegalArgumentException("encoding too short $encoded.length");
|
||||||
int length = ((encoded[0] & 0xFF) << 8) | (encoded[1] & 0xFF);
|
int length = ((encoded[0] & 0xFF) << 8) | (encoded[1] & 0xFF);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.muwire.core.files.FileTree;
|
||||||
import com.muwire.core.files.FileTreeCallback;
|
import com.muwire.core.files.FileTreeCallback;
|
||||||
import com.muwire.core.files.FileUnsharedEvent;
|
import com.muwire.core.files.FileUnsharedEvent;
|
||||||
import com.muwire.core.files.UICommentEvent;
|
import com.muwire.core.files.UICommentEvent;
|
||||||
|
import com.muwire.core.util.DataUtil;
|
||||||
|
|
||||||
import net.i2p.data.Base64;
|
import net.i2p.data.Base64;
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ public class FileManager {
|
||||||
return;
|
return;
|
||||||
UICommentEvent e = new UICommentEvent();
|
UICommentEvent e = new UICommentEvent();
|
||||||
e.setOldComment(sf.getComment());
|
e.setOldComment(sf.getComment());
|
||||||
sf.setComment(comment);
|
sf.setComment(Base64.encode(DataUtil.encodei18nString(comment)));
|
||||||
e.setSharedFile(sf);
|
e.setSharedFile(sf);
|
||||||
revision++;
|
revision++;
|
||||||
core.getEventBus().publish(e);
|
core.getEventBus().publish(e);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.muwire.core.SharedFile;
|
import com.muwire.core.SharedFile;
|
||||||
|
import com.muwire.core.util.DataUtil;
|
||||||
import com.muwire.core.files.FileListCallback;
|
import com.muwire.core.files.FileListCallback;
|
||||||
|
|
||||||
import net.i2p.data.Base64;
|
import net.i2p.data.Base64;
|
||||||
|
@ -106,8 +107,10 @@ public class FilesServlet extends HttpServlet {
|
||||||
sb.append("<Name>").append(Util.escapeHTMLinXML(sf.getFile().getName())).append("</Name>");
|
sb.append("<Name>").append(Util.escapeHTMLinXML(sf.getFile().getName())).append("</Name>");
|
||||||
sb.append("<Path>").append(Util.escapeHTMLinXML(sf.getCachedPath())).append("</Path>");
|
sb.append("<Path>").append(Util.escapeHTMLinXML(sf.getCachedPath())).append("</Path>");
|
||||||
sb.append("<Size>").append(DataHelper.formatSize2Decimal(sf.getCachedLength())).append("B").append("</Size>");
|
sb.append("<Size>").append(DataHelper.formatSize2Decimal(sf.getCachedLength())).append("B").append("</Size>");
|
||||||
if (sf.getComment() != null)
|
if (sf.getComment() != null) {
|
||||||
sb.append("<Comment>").append(Util.escapeHTMLinXML(sf.getComment())).append("</Comment>");
|
String comment = DataUtil.readi18nString(Base64.decode(sf.getComment()));
|
||||||
|
sb.append("<Comment>").append(Util.escapeHTMLinXML(comment)).append("</Comment>");
|
||||||
|
}
|
||||||
// TODO: other stuff
|
// TODO: other stuff
|
||||||
sb.append("</File>");
|
sb.append("</File>");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue