From 65d0eb45599c9230a375639db18697d0e81e4e44 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 27 Aug 2022 16:30:23 +0300 Subject: [PATCH] refactoring + added a hard path dept limit (hack?) Signed-off-by: Alex A. Naanou --- browser.js | 2 +- pwiki/page.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/browser.js b/browser.js index ae3636a..1835c2c 100755 --- a/browser.js +++ b/browser.js @@ -26,7 +26,7 @@ var pouchdbstore = require('./pwiki/store/pouchdb') var store = module.store = { - /* XXX base localstorage... + // XXX base localstorage... __proto__: localstoragestore.localStorageStore, __prefix__: '--pwiki-root:', data: localStorage, diff --git a/pwiki/page.js b/pwiki/page.js index 88f4c4d..a3bb7ab 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -505,6 +505,7 @@ module.Page = object.Constructor('Page', BasePage, { __parser__: parser.parser, + NESTING_DEPTH_LIMIT: 20, NESTING_RECURSION_TEST_THRESHOLD: 50, // Filter that will isolate the page/include/.. from parent filters... @@ -732,9 +733,14 @@ object.Constructor('Page', BasePage, { if(seen.has(full) // nesting path recursion... || (full.length % (this.NESTING_RECURSION_TEST_THRESHOLD || 50) == 0 - && pwpath.split(full).length > 3 - && await page.find() == await page.get('..').find() - && await page.find() == await page.get('../..').find())){ + && (pwpath.split(full).length > 3 + && new Set([ + await page.find(), + await page.get('..').find(), + await page.get('../..').find(), + ]).size == 1 + // XXX HACK??? + || pwpath.split(full).length > (this.NESTING_DEPTH_LIMIT || 20)))){ if(recursive == null){ console.warn( `@${key}(..): ${