refactoring + added a hard path dept limit (hack?)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-27 16:30:23 +03:00
parent 445c115f48
commit 65d0eb4559
2 changed files with 10 additions and 4 deletions

View File

@ -26,7 +26,7 @@ var pouchdbstore = require('./pwiki/store/pouchdb')
var store = var store =
module.store = { module.store = {
/* XXX base localstorage... // XXX base localstorage...
__proto__: localstoragestore.localStorageStore, __proto__: localstoragestore.localStorageStore,
__prefix__: '--pwiki-root:', __prefix__: '--pwiki-root:',
data: localStorage, data: localStorage,

View File

@ -505,6 +505,7 @@ module.Page =
object.Constructor('Page', BasePage, { object.Constructor('Page', BasePage, {
__parser__: parser.parser, __parser__: parser.parser,
NESTING_DEPTH_LIMIT: 20,
NESTING_RECURSION_TEST_THRESHOLD: 50, NESTING_RECURSION_TEST_THRESHOLD: 50,
// Filter that will isolate the page/include/.. from parent filters... // Filter that will isolate the page/include/.. from parent filters...
@ -732,9 +733,14 @@ object.Constructor('Page', BasePage, {
if(seen.has(full) if(seen.has(full)
// nesting path recursion... // nesting path recursion...
|| (full.length % (this.NESTING_RECURSION_TEST_THRESHOLD || 50) == 0 || (full.length % (this.NESTING_RECURSION_TEST_THRESHOLD || 50) == 0
&& pwpath.split(full).length > 3 && (pwpath.split(full).length > 3
&& await page.find() == await page.get('..').find() && new Set([
&& await page.find() == await page.get('../..').find())){ 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){ if(recursive == null){
console.warn( console.warn(
`@${key}(..): ${ `@${key}(..): ${