2005-09-27 jrandom

* Properly suggest filenames for attachments in Syndie (thanks all!)
    * Fixed the Syndie authorization scheme for single user vs. multiuser
This commit is contained in:
jrandom
2005-09-27 22:42:49 +00:00
committed by zzz
parent ab1654c784
commit ef7d1ba964
6 changed files with 44 additions and 8 deletions

View File

@ -274,7 +274,7 @@ public class BlogManager {
}
public boolean authorizeRemote(User user) {
if (isSingleUser()) return true;
return (!user.getAuthenticated() || !user.getAllowAccessRemote());
return (user.getAuthenticated() && user.getAllowAccessRemote());
}
public void configure(String registrationPassword, String remotePassword, String adminPass, String defaultSelector,

View File

@ -620,6 +620,17 @@ public class ArchiveViewerBean {
return "application/octet-stream";
}
public static final boolean getAttachmentShouldShowInline(Map parameters) {
Attachment a = getAttachment(parameters);
if (a == null)
return true;
String mime = a.getMimeType();
if ( (mime != null) && ((mime.startsWith("image/") || mime.startsWith("text/plain"))) )
return true;
else
return false;
}
public static final int getAttachmentContentLength(Map parameters) {
Attachment a = getAttachment(parameters);
if (a != null)
@ -628,6 +639,14 @@ public class ArchiveViewerBean {
return -1;
}
public static final String getAttachmentFilename(Map parameters) {
Attachment a = getAttachment(parameters);
if (a != null)
return a.getName();
else
return "attachment.dat";
}
private static final Attachment getAttachment(Map parameters) {
String blogStr = getString(parameters, PARAM_BLOG);
Hash blog = null;

View File

@ -1,10 +1,16 @@
<%@page autoFlush="false" %><%
<%@page autoFlush="false" import="net.i2p.syndie.web.*" %><%
request.setCharacterEncoding("UTF-8");
java.util.Map params = request.getParameterMap();
response.setContentType(net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentType(params));
int len = net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentLength(params);
response.setContentType(ArchiveViewerBean.getAttachmentContentType(params));
boolean inline = ArchiveViewerBean.getAttachmentShouldShowInline(params);
String filename = ArchiveViewerBean.getAttachmentFilename(params);
if (inline)
response.setHeader("Content-Disposition", "inline; filename=" + filename);
else
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
int len = ArchiveViewerBean.getAttachmentContentLength(params);
if (len >= 0)
response.setContentLength(len);
net.i2p.syndie.web.ArchiveViewerBean.renderAttachment(params, response.getOutputStream());
ArchiveViewerBean.renderAttachment(params, response.getOutputStream());
%>

View File

@ -1,6 +1,7 @@
<%@page import="net.i2p.syndie.web.ArchiveViewerBean" %><jsp:useBean
scope="session" class="net.i2p.syndie.web.PostBean" id="post" /><%
request.setCharacterEncoding("UTF-8");
java.util.Map params = request.getParameterMap();
String id = request.getParameter(ArchiveViewerBean.PARAM_ATTACHMENT);
if (id != null) {
try {
@ -9,6 +10,12 @@ if (id != null) {
%>Attachment <%=attachmentId%> does not exist<%
} else {
response.setContentType(post.getContentType(attachmentId));
boolean inline = ArchiveViewerBean.getAttachmentShouldShowInline(params);
String filename = ArchiveViewerBean.getAttachmentFilename(params);
if (inline)
response.setHeader("Content-Disposition", "inline; filename=" + filename);
else
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
post.writeAttachmentData(attachmentId, response.getOutputStream());
}
} catch (NumberFormatException nfe) {}

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.266 2005/09/26 18:45:53 jrandom Exp $
$Id: history.txt,v 1.267 2005/09/27 02:17:41 jrandom Exp $
2005-09-27 jrandom
* Properly suggest filenames for attachments in Syndie (thanks all!)
* Fixed the Syndie authorization scheme for single user vs. multiuser
2005-09-27 jrandom
* I2PTunnel bugfix (thanks Complication!)

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.246 $ $Date: 2005/09/26 18:45:52 $";
public final static String ID = "$Revision: 1.247 $ $Date: 2005/09/27 02:17:40 $";
public final static String VERSION = "0.6.0.6";
public final static long BUILD = 6;
public final static long BUILD = 7;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);