Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/en_US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"duplicated_path": "Duplicated path",
"Link sharing is disabled": "Link sharing is disabled",
"successfully_saved_the_page": "Successfully saved the page",
"you_can_not_create_page_with_this_name": "You can not create page with this name",
"you_can_not_create_page_with_this_name_or_hierarchy": "You can not create page with this name or page hierarchy",
"not_allowed_to_see_this_page": "You cannot see this page",
"Confirm": "Confirm",
"Successfully requested": "Successfully requested.",
Expand Down
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/fr_FR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"duplicated_path": "Chemin dupliqué",
"Link sharing is disabled": "Le partage est désactivé",
"successfully_saved_the_page": "Page sauvegardée",
"you_can_not_create_page_with_this_name": "Vous ne pouvez pas créer cette page",
"you_can_not_create_page_with_this_name_or_hierarchy": "Vous ne pouvez pas créer de page avec ce nom ou cette hiérarchie de pages",
"not_allowed_to_see_this_page": "Vous ne pouvez pas voir cette page",
"Confirm": "Confirmer",
"Successfully requested": "Demande envoyée.",
Expand Down
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/ja_JP/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"duplicated_path": "重複したパス",
"Link sharing is disabled": "リンクのシェアは無効化されています",
"successfully_saved_the_page": "ページが正常に保存されました",
"you_can_not_create_page_with_this_name": "この名前でページを作成することはできません",
"you_can_not_create_page_with_this_name_or_hierarchy": "この名前、または階層でページを作成することはできません",
"not_allowed_to_see_this_page": "このページは閲覧できません",
"Confirm": "確認",
"Successfully requested": "正常に処理を受け付けました",
Expand Down
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/zh_CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"duplicated_path": "Duplicated path",
"Link sharing is disabled": "你不允许分享该链接",
"successfully_saved_the_page": "成功地保存了该页面",
"you_can_not_create_page_with_this_name": "您无法使用此名称创建页面",
"you_can_not_create_page_with_this_name_or_hierarchy": "您無法使用此名稱或頁面層級建立頁面",
"not_allowed_to_see_this_page": "你不能看到这个页面",
"Confirm": "确定",
"Successfully requested": "进程成功接受",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const useNewPageInput = (): UseNewPageInput => {
const isCreatable = pagePathUtils.isCreatablePage(newPagePath);

if (!isCreatable) {
toastWarning(t('you_can_not_create_page_with_this_name'));
toastWarning(t('you_can_not_create_page_with_this_name_or_hierarchy'));
return;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/page-path-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import escapeStringRegexp from 'escape-string-regexp';

import { IUser } from '~/interfaces';
import type { IUser } from '~/interfaces';

import { isValidObjectId } from '../objectid-utils';
import { addTrailingSlash } from '../path-utils';
Expand Down Expand Up @@ -117,6 +117,7 @@ const restrictedPatternsToCreate: Array<RegExp> = [
/^\/(_search|_private-legacy-pages)(\/.*|$)/,
/^\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\/.*|$)/,
/^\/user(?:\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1
/^(\/.+){500,}$/, // avoid deep layer path. see: https://regex101.com/r/L0kzOD/1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

500も一般的な利用の範囲では現実的ではないので、130にしましょう

考え方

ユーザーの潜在ニーズとして、MongoDB 内の全ページを一般的な OS のファイルシステム上にディレクトリツリーとして再構築できるのがのぞましい。その際の最大階層はいくつか?

参考

image

image

裏取り

https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1

Apple の方は

You should assume that the number of directories in a path is limited to 100 or fewer.

のような記述は見当たらず…
Claude を問い詰めたら「質問の根拠となる情報を適切に示せず、誤った情報を述べてしまい大変失礼いたしました。」と謝られた。

だが Win に 260 char 制限があるのは確かなので、今回は130とする。

];
export const isCreatablePage = (path: string): boolean => {
return !restrictedPatternsToCreate.some(pattern => path.match(pattern));
Expand Down
Loading