|
|
@@ -64,6 +64,24 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ function encodePagesPath(pages) {
|
|
|
+ pages.forEach(function(page) {
|
|
|
+ if (!page.path) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ page.path = encodePagePath(page.path);
|
|
|
+ });
|
|
|
+ return pages;
|
|
|
+ }
|
|
|
+
|
|
|
+ function encodePagePath(path) {
|
|
|
+ var paths = path.split('/');
|
|
|
+ paths.forEach(function(item, index) {
|
|
|
+ paths[index] = encodeURIComponent(item);
|
|
|
+ });
|
|
|
+ return paths.join('/');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* switch action by behaviorType
|
|
|
*/
|
|
|
@@ -193,7 +211,7 @@ module.exports = function(crowi, app) {
|
|
|
seener_threshold: SEENER_THRESHOLD,
|
|
|
};
|
|
|
renderVars.pager = generatePager(pagerOptions);
|
|
|
- renderVars.pages = pageList;
|
|
|
+ renderVars.pages = encodePagesPath(pageList);
|
|
|
res.render('customlayout-selector/page_list', renderVars);
|
|
|
}).catch(function(err) {
|
|
|
debug('Error on rendering pageListShow', err);
|
|
|
@@ -248,7 +266,7 @@ module.exports = function(crowi, app) {
|
|
|
if (page.redirectTo) {
|
|
|
debug(`Redirect to '${page.redirectTo}'`);
|
|
|
isRedirect = true;
|
|
|
- return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + page.path));
|
|
|
+ return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + encodePagePath(page.path)));
|
|
|
}
|
|
|
|
|
|
renderVars.page = page;
|
|
|
@@ -320,7 +338,7 @@ module.exports = function(crowi, app) {
|
|
|
seener_threshold: SEENER_THRESHOLD,
|
|
|
};
|
|
|
renderVars.pager = generatePager(pagerOptions);
|
|
|
- renderVars.pages = pageList;
|
|
|
+ renderVars.pages = encodePagesPath(pageList);
|
|
|
|
|
|
return Promise.resolve();
|
|
|
})
|
|
|
@@ -379,7 +397,7 @@ module.exports = function(crowi, app) {
|
|
|
pagerOptions.length = pageList.length;
|
|
|
|
|
|
renderVars.pager = generatePager(pagerOptions);
|
|
|
- renderVars.pages = pageList;
|
|
|
+ renderVars.pages = encodePagesPath(pageList);
|
|
|
res.render('customlayout-selector/page_list', renderVars);
|
|
|
}).catch(function(err) {
|
|
|
debug('Error on rendering deletedPageListShow', err);
|
|
|
@@ -408,7 +426,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
res.render('customlayout-selector/page_list', {
|
|
|
path: '/',
|
|
|
- pages: pages,
|
|
|
+ pages: encodePagesPath(pages),
|
|
|
pager: generatePager({offset: 0, limit: 50})
|
|
|
});
|
|
|
}).catch(function(err) {
|
|
|
@@ -426,7 +444,7 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
|
|
|
if (pageData.redirectTo) {
|
|
|
- return res.redirect(encodeURI(pageData.redirectTo + '?redirectFrom=' + pageData.path));
|
|
|
+ return res.redirect(encodeURI(pageData.redirectTo + '?redirectFrom=' + encodePagePath(pageData.path)));
|
|
|
}
|
|
|
|
|
|
var renderVars = {
|
|
|
@@ -519,7 +537,7 @@ module.exports = function(crowi, app) {
|
|
|
return ;
|
|
|
}
|
|
|
if (req.query.revision) {
|
|
|
- return res.redirect(encodeURI(path));
|
|
|
+ return res.redirect(encodePagePath(path));
|
|
|
}
|
|
|
|
|
|
if (isMarkdown) {
|
|
|
@@ -529,13 +547,13 @@ module.exports = function(crowi, app) {
|
|
|
Page.hasPortalPage(path + '/', req.user)
|
|
|
.then(function(page) {
|
|
|
if (page) {
|
|
|
- return res.redirect(encodeURI(path) + '/');
|
|
|
+ return res.redirect(encodePagePath(path) + '/');
|
|
|
} else {
|
|
|
|
|
|
var fixed = Page.fixToCreatableName(path)
|
|
|
if (fixed !== path) {
|
|
|
debug('fixed page name', fixed)
|
|
|
- res.redirect(encodeURI(fixed));
|
|
|
+ res.redirect(encodePagePath(fixed));
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
@@ -568,7 +586,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
debug('notify: ', notify);
|
|
|
|
|
|
- var redirectPath = encodeURI(path);
|
|
|
+ var redirectPath = encodePagePath(path);
|
|
|
var pageData = {};
|
|
|
var updateOrCreate;
|
|
|
var previousRevision = false;
|
|
|
@@ -657,7 +675,7 @@ module.exports = function(crowi, app) {
|
|
|
return Promise.resolve(pageData);
|
|
|
}).then(function(page) {
|
|
|
|
|
|
- return res.redirect(encodeURI(page.path));
|
|
|
+ return res.redirect(encodePagePath(page.path));
|
|
|
}).catch(function(err) {
|
|
|
return res.redirect('/');
|
|
|
});
|
|
|
@@ -709,7 +727,7 @@ module.exports = function(crowi, app) {
|
|
|
pagerOptions.length = pages.length;
|
|
|
|
|
|
var result = {};
|
|
|
- result.pages = pages;
|
|
|
+ result.pages = encodePagesPath(pages);
|
|
|
return res.json(ApiResponse.success(result));
|
|
|
}).catch(function(err) {
|
|
|
return res.json(ApiResponse.error(err));
|