Author: toad
Date: 2006-11-11 00:51:36 +0000 (Sat, 11 Nov 2006)
New Revision: 10873

Modified:
   trunk/freenet/src/freenet/client/FetcherContext.java
   trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
   trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/NodeARKInserter.java
   trunk/freenet/src/freenet/node/NodeClientCore.java
   trunk/freenet/src/freenet/node/TextModeClientInterface.java
   trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
   trunk/freenet/src/freenet/node/updater/NodeUpdater.java
Log:
New option ignoreTooManyPathComponents. Defaults to true.
If false, we enforce (even in FCP) the policy of no extra /path/components 
beyond what is needed to fetch a file.

Modified: trunk/freenet/src/freenet/client/FetcherContext.java
===================================================================
--- trunk/freenet/src/freenet/client/FetcherContext.java        2006-11-10 
21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/client/FetcherContext.java        2006-11-11 
00:51:36 UTC (rev 10873)
@@ -45,6 +45,7 @@
         * return the manifest contents as data. */
        public boolean returnZIPManifests;
        public final HealingQueue healingQueue;
+       public final boolean ignoreTooManyPathComponents;

        public FetcherContext(long curMaxLength, 
                        long curMaxTempLength, int maxMetadataSize, int 
maxRecursionLevel, int maxArchiveRestarts, int maxArchiveLevels,
@@ -53,7 +54,7 @@
                        boolean allowSplitfiles, boolean followRedirects, 
boolean localRequestOnly,
                        int maxDataBlocksPerSegment, int 
maxCheckBlocksPerSegment,
                        RandomSource random, ArchiveManager archiveManager, 
BucketFactory bucketFactory,
-                       ClientEventProducer producer, boolean 
cacheLocalRequests, USKManager uskManager, HealingQueue hq) {
+                       ClientEventProducer producer, boolean 
cacheLocalRequests, USKManager uskManager, HealingQueue hq, boolean 
ignoreTooManyPathComponents) {
                this.maxOutputLength = curMaxLength;
                this.uskManager = uskManager;
                this.maxTempLength = curMaxTempLength;
@@ -77,6 +78,7 @@
                this.maxCheckBlocksPerSegment = maxCheckBlocksPerSegment;
                this.cacheLocalRequests = cacheLocalRequests;
                this.healingQueue = hq;
+               this.ignoreTooManyPathComponents = ignoreTooManyPathComponents;
        }

        public FetcherContext(FetcherContext ctx, int maskID, boolean 
keepProducer) {
@@ -86,6 +88,7 @@
                else
                        this.eventProducer = new SimpleEventProducer();
                this.uskManager = ctx.uskManager;
+               this.ignoreTooManyPathComponents = 
ctx.ignoreTooManyPathComponents;
                if(maskID == IDENTICAL_MASK) {
                        this.maxOutputLength = ctx.maxOutputLength;
                        this.maxMetadataSize = ctx.maxMetadataSize;

Modified: trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
===================================================================
--- trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java     
2006-11-10 21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java     
2006-11-11 00:51:36 UTC (rev 10873)
@@ -43,6 +43,7 @@
        private final HealingQueue healingQueue;
        /** See comments in Node */
        private final boolean cacheLocalRequests;
+       private final boolean forceDontIgnoreTooManyPathComponents;
        static final int MAX_RECURSION = 10;
        static final int MAX_ARCHIVE_RESTARTS = 2;
        static final int MAX_ARCHIVE_LEVELS = 4;
@@ -76,7 +77,7 @@
        static final int SPLITFILE_CHECK_BLOCKS_PER_SEGMENT = 64;


-       public HighLevelSimpleClientImpl(NodeClientCore node, ArchiveManager 
mgr, BucketFactory bf, RandomSource r, boolean cacheLocalRequests, short 
priorityClass) {
+       public HighLevelSimpleClientImpl(NodeClientCore node, ArchiveManager 
mgr, BucketFactory bf, RandomSource r, boolean cacheLocalRequests, short 
priorityClass, boolean forceDontIgnoreTooManyPathComponents) {
                this.core = node;
                archiveManager = mgr;
                this.priorityClass = priorityClass;
@@ -92,6 +93,7 @@
                this.persistentBucketFactory = 
node.persistentEncryptedTempBucketFactory;
                this.healingQueue = node.getHealingQueue();
                this.blockEncoder = node.backgroundBlockEncoder;
+               this.forceDontIgnoreTooManyPathComponents = 
forceDontIgnoreTooManyPathComponents;
        }

        public void setMaxLength(long maxLength) {
@@ -183,7 +185,8 @@
                                FETCH_SPLITFILES, FOLLOW_REDIRECTS, 
LOCAL_REQUESTS_ONLY,
                                MAX_SPLITFILE_BLOCKS_PER_SEGMENT, 
MAX_SPLITFILE_CHECK_BLOCKS_PER_SEGMENT,
                                random, archiveManager, bucketFactory, 
globalEventProducer, 
-                               cacheLocalRequests, core.uskManager, 
healingQueue);
+                               cacheLocalRequests, core.uskManager, 
healingQueue, 
+                               forceDontIgnoreTooManyPathComponents ? false : 
core.ignoreTooManyPathComponents);
        }

        public InserterContext getInserterContext(boolean forceNonPersistent) {

Modified: trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileFetcher.java       
2006-11-10 21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/client/async/SingleFileFetcher.java       
2006-11-11 00:51:36 UTC (rev 10873)
@@ -197,7 +197,7 @@
                        }
                        result = new FetchResult(result, data);
                }
-               if(!metaStrings.isEmpty()) {
+               if((!ctx.ignoreTooManyPathComponents) && 
(!metaStrings.isEmpty())) {
                        // Some meta-strings left
                        if(addedMetaStrings > 0) {
                                // Should this be an error?
@@ -374,7 +374,7 @@
                                        addDecompressor(codec);
                                }

-                               if(isFinal) {
+                               if(isFinal && !ctx.ignoreTooManyPathComponents) 
{
                                        if(!metaStrings.isEmpty()) {
                                                // Some meta-strings left
                                                if(addedMetaStrings > 0) {

Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2006-11-10 
21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2006-11-11 
00:51:36 UTC (rev 10873)
@@ -358,7 +358,7 @@

                        SimpleToadletServer server = new 
SimpleToadletServer(fproxyConfig, core);

-                       HighLevelSimpleClient client = 
core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+                       HighLevelSimpleClient client = 
core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, true);

                        core.setToadletContainer(server);
                        random = new byte[32];

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-11-10 21:15:18 UTC (rev 
10872)
+++ trunk/freenet/src/freenet/node/Node.java    2006-11-11 00:51:36 UTC (rev 
10873)
@@ -1281,7 +1281,7 @@
                pluginManager = new PluginManager(this);
                pluginManager2 = new freenet.plugin.PluginManager(this);

-               FetcherContext ctx = 
clientCore.makeClient((short)0).getFetcherContext();
+               FetcherContext ctx = clientCore.makeClient((short)0, 
true).getFetcherContext();

                ctx.allowSplitfiles = false;
                ctx.dontEnterImplicitArchives = true;

Modified: trunk/freenet/src/freenet/node/NodeARKInserter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeARKInserter.java 2006-11-10 21:15:18 UTC 
(rev 10872)
+++ trunk/freenet/src/freenet/node/NodeARKInserter.java 2006-11-11 00:51:36 UTC 
(rev 10873)
@@ -133,7 +133,7 @@

                inserter = new ClientPutter(this, b, uri,
                                        new ClientMetadata("text/plain") /* it 
won't quite fit in an SSK anyway */, 
-                                       
node.clientCore.makeClient((short)0).getInserterContext(true),
+                                       node.clientCore.makeClient((short)0, 
true).getInserterContext(true),
                                        
node.clientCore.requestStarters.chkPutScheduler, 
node.clientCore.requestStarters.sskPutScheduler, 
RequestStarter.INTERACTIVE_PRIORITY_CLASS, false, false, this, null, null);

                try {

Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java  2006-11-10 21:15:18 UTC 
(rev 10872)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java  2006-11-11 00:51:36 UTC 
(rev 10873)
@@ -15,6 +15,7 @@
 import freenet.clients.http.BookmarkManager;
 import freenet.clients.http.FProxyToadlet;
 import freenet.clients.http.SimpleToadletServer;
+import freenet.config.BooleanCallback;
 import freenet.config.Config;
 import freenet.config.InvalidConfigValueException;
 import freenet.config.StringCallback;
@@ -81,6 +82,8 @@
        // FIXME why isn't this just in fproxy?
        public BookmarkManager bookmarkManager;
        public final BackgroundBlockEncoder backgroundBlockEncoder;
+       /** If true, allow extra path components at the end of URIs */
+       public boolean ignoreTooManyPathComponents;

        // Client stuff that needs to be configged - FIXME
        static final int MAX_ARCHIVE_HANDLERS = 200; // don't take up much 
RAM... FIXME
@@ -192,6 +195,21 @@
                                                random, 0, 2, 1, 0, 0, new 
SimpleEventProducer(), 
                                                
!Node.DONT_CACHE_LOCAL_REQUESTS, uskManager, backgroundBlockEncoder), 
RequestStarter.PREFETCH_PRIORITY_CLASS, 512 /* FIXME make configurable */);

+               nodeConfig.register("ignoreTooManyPathComponents", true, 
sortOrder++, true, false, "Ignore too many path components", 
+                               "If true, the node won't generate 
TOO_MANY_PATH_COMPONENTS errors when a URI is fed to it which has extra, 
meaningless subdirs (/blah/blah) on the end beyond what is needed to fetch the 
key (for example, old CHKs will often have filenames stuck on the end which 
weren't part of the original insert; this is obsolete because we can now 
include the filename, and it is confusing to be able to add arbitrary strings 
to a URI, and it makes them hard to compare). Only enable this option if you 
need it for compatibility with older apps; it will be removed soon.", new 
BooleanCallback() {
+
+                                       public boolean get() {
+                                               return 
ignoreTooManyPathComponents;
+                                       }
+
+                                       public void set(boolean val) throws 
InvalidConfigValueException {
+                                               ignoreTooManyPathComponents = 
val;
+                                       }
+                       
+               });
+               
+               ignoreTooManyPathComponents = 
nodeConfig.getBoolean("ignoreTooManyPathComponents");
+               
        }


@@ -681,9 +699,13 @@
        }

        public HighLevelSimpleClient makeClient(short prioClass) {
-               return new HighLevelSimpleClientImpl(this, archiveManager, 
tempBucketFactory, random, !Node.DONT_CACHE_LOCAL_REQUESTS, prioClass);
+               return makeClient(prioClass, false);
        }

+       public HighLevelSimpleClient makeClient(short prioClass, boolean 
forceDontIgnoreTooManyPathComponents) {
+               return new HighLevelSimpleClientImpl(this, archiveManager, 
tempBucketFactory, random, !Node.DONT_CACHE_LOCAL_REQUESTS, prioClass, 
forceDontIgnoreTooManyPathComponents);
+       }
+       
        public FCPServer getFCPServer() {
                return fcpServer;
        }

Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-11-10 
21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-11-11 
00:51:36 UTC (rev 10873)
@@ -64,7 +64,7 @@
        this.n = server.n;
        this.core = server.n.clientCore;
        this.r = server.r;
-        client = core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+        client = core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, 
true);
        this.streams = new Hashtable();
        this.downloadsDir = server.downloadsDir;
        this.in = in;

Modified: trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java   
2006-11-10 21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java   
2006-11-11 00:51:36 UTC (rev 10873)
@@ -86,7 +86,7 @@
                }

                if(direct) {
-               HighLevelSimpleClient client = 
core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+               HighLevelSimpleClient client = 
core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, true);
                        TextModeClientInterface directTMCI =
                                new TextModeClientInterface(node, client, 
core.downloadDir, System.in, System.out);
                        Thread t = new Thread(directTMCI, "Direct text mode 
interface");

Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java     2006-11-10 
21:15:18 UTC (rev 10872)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java     2006-11-11 
00:51:36 UTC (rev 10873)
@@ -95,12 +95,12 @@
                alert.isValid(false);
                core.alerts.register(alert);

-               FetcherContext tempContext = 
core.makeClient((short)0).getFetcherContext();             
+               FetcherContext tempContext = core.makeClient((short)0, 
true).getFetcherContext();               
                tempContext.allowSplitfiles = true;
                tempContext.dontEnterImplicitArchives = false;
                this.ctx = tempContext;

-               ctxRevocation = core.makeClient((short)0).getFetcherContext();
+               ctxRevocation = core.makeClient((short)0, 
true).getFetcherContext();
                ctxRevocation.allowSplitfiles = false;
                ctxRevocation.cacheLocalRequests = false;
                ctxRevocation.maxArchiveLevels = 1;


Reply via email to