From 7e5753cdd8b05258ca356d294afc04f995081494 Mon Sep 17 00:00:00 2001 From: Raphael Wegmueller Date: Tue, 24 Sep 2024 10:23:48 +0200 Subject: [PATCH 1/3] fix: reject paths with illegal characters (#807) --- src/extension/_locales/en/messages.json | 4 +-- src/extension/module.js | 38 ++++++++++++++++++------- test/bulk-preview.test.js | 31 ++++++++++++++++++++ test/edit-preview.test.js | 23 +++++++++++++++ test/utils.js | 2 +- 5 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/extension/_locales/en/messages.json b/src/extension/_locales/en/messages.json index 67d5e2675..e6d6c863f 100644 --- a/src/extension/_locales/en/messages.json +++ b/src/extension/_locales/en/messages.json @@ -34,10 +34,10 @@ "message": "Bulk operation failed. Please try again later." }, "bulk_error_illegal_file_name": { - "message": "Only normalized, small latin letters, digits and hyphens are allowed in file names. The following file name contains illegal characters:" + "message": "Only normalized, small latin letters, digits and hyphens are allowed in file and folder names. The following path contains illegal characters:" }, "bulk_error_illegal_file_names": { - "message": "Only normalized, small latin letters, digits and hyphens are allowed in file names. The following file names contain illegal characters:" + "message": "Only normalized, small latin letters, digits and hyphens are allowed in file and folder names. The following paths contain illegal characters:" }, "bulk_error_preview_login_required": { "message": "You need to sign in to generate the preview of more than 100 files." diff --git a/src/extension/module.js b/src/extension/module.js index 441896cb7..b9b1bd1c4 100644 --- a/src/extension/module.js +++ b/src/extension/module.js @@ -1361,6 +1361,21 @@ import sampleRUM from './rum.js'; text: i18n(sk, 'preview'), action: async () => { const { status, location } = sk; + if (status.edit.illegalPath) { + sk.showModal( + [ + i18n(sk, 'bulk_error_illegal_file_name'), + status.edit.illegalPath, + createTag({ + tag: 'button', + text: i18n(sk, 'close'), + }), + ], + true, + 2, + ); + return; + } if (status.edit && status.edit.sourceLocation && status.edit.sourceLocation.startsWith('onedrive:') && !location.pathname.startsWith('/:x:/')) { @@ -1692,7 +1707,7 @@ import sampleRUM from './rum.js'; // omit docx extension on sharepoint ext = ''; } - if (type === 'xlsx' || type === 'spreadsheet') { + if (type === 'xlsx' || (type === 'spreadsheet' && ext !== '.xlsx')) { // use json extension for spreadsheets ext = '.json'; } @@ -1709,10 +1724,13 @@ import sampleRUM from './rum.js'; return `${folder}${folder.endsWith('/') ? '' : '/'}${file}${ext}`; }; - const validateWebPaths = (paths) => { - const illegal = paths - .filter((path) => path.startsWith('!ILLEGAL!_')) - .map((path) => path.substring(10)); + const validateWebPaths = (status, paths) => { + const { webPath: folder, edit } = status; + const illegal = edit.illegalPath + ? [edit.illegalPath] // illegal parent path + : paths + .filter((path) => path.startsWith('!ILLEGAL!_')) + .map((path) => `${folder}${folder.endsWith('/') ? '' : '/'}${path.substring(10)}`); if (illegal.length > 0) { sk.showModal({ message: [ @@ -1770,7 +1788,7 @@ import sampleRUM from './rum.js'; // use path in icon svg to determine type const typeHint = (row.querySelector(':scope div[role="gridcell"] > div:nth-child(1) path:nth-child(1)') // list layout || row.querySelector(':scope div[role="gridcell"] > div:nth-of-type(1) > div:nth-child(2) path:nth-child(1)')) // grid layout - .getAttribute('d').slice(-4); + ?.getAttribute('d').slice(-4); let type = 'unknown'; if (typeHint) { if (typeHint === folderId || typeHint === sharedFolderId) { @@ -1962,7 +1980,7 @@ import sampleRUM from './rum.js'; host, }) => { const { config, status } = sk; - const paths = validateWebPaths(bulkSelection + const paths = validateWebPaths(status, bulkSelection .map((item) => toWebPath(status.webPath, item))); if (paths.length === 0) { return; @@ -2094,7 +2112,7 @@ import sampleRUM from './rum.js'; const doBulkCopyUrls = async (hostProperty) => { const { config, status } = sk; - const paths = validateWebPaths(bulkSelection + const paths = validateWebPaths(status, bulkSelection .map((item) => toWebPath(status.webPath, item))); if (paths.length === 0) { return; @@ -2147,7 +2165,7 @@ import sampleRUM from './rum.js'; host: sk.config.innerHost, }); fireEvent(sk, 'previewed', { - paths: validateWebPaths(bulkSelection + paths: validateWebPaths(status, bulkSelection .map((item) => toWebPath(status.webPath, item))), }); sampleRUM('sidekick:bulk:previewed'); @@ -2181,7 +2199,7 @@ import sampleRUM from './rum.js'; host: sk.config.host || sk.config.outerHost, }); fireEvent(sk, 'published', { - paths: validateWebPaths(bulkSelection + paths: validateWebPaths(status, bulkSelection .map((item) => toWebPath(status.webPath, item))), }); sampleRUM('sidekick:bulk:published'); diff --git a/test/bulk-preview.test.js b/test/bulk-preview.test.js index aa84d1087..3a3616a5f 100644 --- a/test/bulk-preview.test.js +++ b/test/bulk-preview.test.js @@ -440,6 +440,7 @@ describe('Test bulk preview plugin', () => { browser, page, plugin: 'bulk-preview', + pluginSleep: 1000, acceptDialogs: true, fixture, url: setup.getUrl('edit', 'admin'), @@ -455,6 +456,36 @@ describe('Test bulk preview plugin', () => { ); }).timeout(IT_DEFAULT_TIMEOUT); + it('Bulk preview plugin rejects illegal folder name in gdrive', async () => { + const { setup, fixture } = TESTS[1]; + const statusResponse = { ...setup.apiResponse('admin') }; + statusResponse.edit.illegalPath = '/this/path/is not/legal'; + nock.sidekick(setup); + nock('https://admin.hlx.page/status') + .get(/.*/) + .twice() + .reply(200, statusResponse); + const { notification } = await new SidekickTest({ + browser, + page, + plugin: 'bulk-preview', + pluginSleep: 1000, + acceptDialogs: true, + fixture, + url: setup.getUrl('edit', 'admin'), + loadModule: true, + pre: (p) => p.evaluate(() => { + // select file + document.getElementById('file-gdoc').click(); + }), + }).run(); + assert.ok( + notification?.message?.includes(statusResponse.edit.illegalPath), + 'Did not reject illegal folder name', + ); + delete statusResponse.edit.illegalPath; + }).timeout(IT_DEFAULT_TIMEOUT); + it('Bulk preview plugin handles docx and xlsx errors in gdrive', async () => { const { setup } = TESTS[1]; nock.sidekick(setup); diff --git a/test/edit-preview.test.js b/test/edit-preview.test.js index 61f9198ab..2972ee3ad 100644 --- a/test/edit-preview.test.js +++ b/test/edit-preview.test.js @@ -292,4 +292,27 @@ describe('Test editor preview plugin', () => { assert.ok(notification.message.includes('429'), 'Reload plugin does not show modal on 429'); assert.ok(notification.message.includes('Microsoft SharePoint'), 'Reload plugin does not mention onedrive'); }).timeout(IT_DEFAULT_TIMEOUT); + + it('Editor preview plugin rejects illegal paths', async () => { + const setup = new Setup('blog'); + const statusResponse = { ...setup.apiResponse('html') }; + statusResponse.edit.illegalPath = '/this/path/is not/legal'; + nock.sidekick(setup); + nock('https://admin.hlx.page/status') + .get(/.*/) + .reply(200, statusResponse); + const test = new SidekickTest({ + browser, + page, + setup, + plugin: 'edit-preview', + url: setup.getUrl('edit'), + }); + const { notification: { message } = {} } = await test.run(); + assert.ok( + message?.includes(statusResponse.edit.illegalPath), + 'Did not reject path with illegal characters', + ); + delete statusResponse.edit.illegalPath; + }).timeout(IT_DEFAULT_TIMEOUT); }); diff --git a/test/utils.js b/test/utils.js index cdd61f6e4..6e7c859d0 100644 --- a/test/utils.js +++ b/test/utils.js @@ -9,7 +9,7 @@ * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -/* eslint-disable max-classes-per-file */ +/* eslint-disable max-classes-per-file, import/no-extraneous-dependencies */ /* eslint-env mocha */ import v8 from 'node:v8'; import assert from 'assert'; From a2248c1ea7631eb49dcbb2eb84f82f2f7a2f36d8 Mon Sep 17 00:00:00 2001 From: Richard Geraghty Date: Tue, 24 Sep 2024 01:36:51 -0700 Subject: [PATCH 2/3] chore: latest translations (#821) Co-authored-by: walf --- src/extension/_locales/de/messages.json | 2 +- src/extension/_locales/fr/messages.json | 8 ++++---- src/extension/_locales/it/messages.json | 8 ++++---- src/extension/_locales/ja/messages.json | 10 +++++----- src/extension/_locales/ko/messages.json | 6 +++--- src/extension/_locales/pt_BR/messages.json | 12 ++++++------ src/extension/_locales/zh_CN/messages.json | 8 ++++---- src/extension/_locales/zh_TW/messages.json | 8 ++++---- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/extension/_locales/de/messages.json b/src/extension/_locales/de/messages.json index f30d28c2b..fd0fd1261 100644 --- a/src/extension/_locales/de/messages.json +++ b/src/extension/_locales/de/messages.json @@ -405,7 +405,7 @@ "message": "Zugriff abgelaufen. Melden Sie sich erneut an, um fortzufahren." }, "error_site_403": { - "message": "Zugriff verweigert. Versuchen Sie, sich mit einem anderen Benutzer anzumelden, oder bitten Sie Ihren Administrator um ausreichende Berechtigungen." + "message": "Zugriff verweigert. Versuchen Sie, sich mit einem anderen Benutzerkonto anzumelden, oder bitten Sie Ihre bzw. Ihren Admin um ausreichende Berechtigungen." }, "error_status_403": { "message": "403 Verboten: Bitten Sie Ihre bzw. Ihren Admin um ausreichende Berechtigungen." diff --git a/src/extension/_locales/fr/messages.json b/src/extension/_locales/fr/messages.json index 1a4c84b8e..aa7652c68 100644 --- a/src/extension/_locales/fr/messages.json +++ b/src/extension/_locales/fr/messages.json @@ -207,7 +207,7 @@ "message": "URL du contenu : https://..." }, "config_manual_org_placeholder": { - "description": "Nom de l'organisation tel que dans le service de configuration", + "description": "Nom de l’organisation tel que dans le service de configuration", "message": "Nom d’organisation" }, "config_manual_previewHost_placeholder": { @@ -402,10 +402,10 @@ "message": "Connectez-vous pour continuer." }, "error_site_401_relogin": { - "message": "Accès expiré. Veuillez vous reconnecter pour continuer." + "message": "Accès arrivé à expiration. Reconnectez-vous pour continuer." }, "error_site_403": { - "message": "Accès refusé. Essayez de vous connecter avec un autre utilisateur ou demandez à votre administrateur des autorisations suffisantes." + "message": "Accès refusé. Essayez de vous connecter avec une autre identité ou demandez à votre équipe d’administration des autorisations suffisantes." }, "error_status_403": { "message": "403 Accès interdit : demandez les autorisations nécessaires à votre administrateur ou à votre administratrice." @@ -625,7 +625,7 @@ "message": "Se déconnecter" }, "user_relogin": { - "message": "Reconnectez-vous" + "message": "Se reconnecter" }, "user_switch": { "message": "Changer d'utilisateur" diff --git a/src/extension/_locales/it/messages.json b/src/extension/_locales/it/messages.json index 788dc0ec3..1847974fb 100644 --- a/src/extension/_locales/it/messages.json +++ b/src/extension/_locales/it/messages.json @@ -399,13 +399,13 @@ "message": "Questo è un documento Microsoft Excel. Convertilo in Fogli Google: File > Salva come foglio Google" }, "error_site_401": { - "message": "Effettua l'accesso per continuare." + "message": "Accedi per continuare." }, "error_site_401_relogin": { - "message": "Accesso scaduto. Per continuare, effettua di nuovo l'accesso." + "message": "Accesso scaduto. Accedi di nuovo per continuare." }, "error_site_403": { - "message": "Accesso negato. Prova ad accedere con un altro utente o chiedi all'amministratore le autorizzazioni necessarie." + "message": "Accesso negato. Prova ad accedere con un altro utente o chiedi all’amministratore le autorizzazioni necessarie." }, "error_status_403": { "message": "403 - Non consentito: chiedi all’amministratore le autorizzazioni necessarie." @@ -438,7 +438,7 @@ "message": "Risposta del server non valida. Controlla la configurazione o l’URL di Sidekick." }, "error_view_description": { - "message": "Messaggio di errore intuitivo." + "message": "Messaggio di errore descrittivo." }, "extensions": { "message": "Estensioni" diff --git a/src/extension/_locales/ja/messages.json b/src/extension/_locales/ja/messages.json index 853c99657..76dd4e5a9 100644 --- a/src/extension/_locales/ja/messages.json +++ b/src/extension/_locales/ja/messages.json @@ -207,7 +207,7 @@ "message": "コンテンツ URL : https://..." }, "config_manual_org_placeholder": { - "description": "設定サービスに含まれる組織名", + "description": "設定サービスでの組織名", "message": "組織名" }, "config_manual_previewHost_placeholder": { @@ -399,13 +399,13 @@ "message": "これは、Microsoft Excel ドキュメントです。[ファイル] > [Google スプレッドシートとして保存] を選択し、Google スプレッドシートに変換してください" }, "error_site_401": { - "message": "続行するにはサインインしてください。" + "message": "続行するには、ログインしてください。" }, "error_site_401_relogin": { - "message": "アクセス期限切れ。続行するには、もう一度サインインしてください。" + "message": "アクセスの有効期限が切れています。続行するには、もう一度ログインしてください。" }, "error_site_403": { - "message": "アクセスが拒否されました。別のユーザーでサインインするか、管理者に十分な権限を問い合わせてください。" + "message": "アクセスが拒否されました。別のユーザーでログインするか、管理者に十分な権限を求めてください。" }, "error_status_403": { "message": "403 Forbidden:管理者に十分な許可を求めてください。" @@ -625,7 +625,7 @@ "message": "ログアウト" }, "user_relogin": { - "message": "もう一度サインイン" + "message": "もう一度ログイン" }, "user_switch": { "message": "ユーザーを切り替え" diff --git a/src/extension/_locales/ko/messages.json b/src/extension/_locales/ko/messages.json index aa392adbe..0e3142870 100644 --- a/src/extension/_locales/ko/messages.json +++ b/src/extension/_locales/ko/messages.json @@ -405,7 +405,7 @@ "message": "액세스가 만료되었습니다. 계속하려면 다시 로그인하십시오." }, "error_site_403": { - "message": "액세스가 거부되었습니다. 다른 사용자로 로그인하거나 관리자에게 충분한 권한을 요청하십시오." + "message": "액세스가 거부되었습니다. 다른 사용자로 로그인을 시도하거나 관리자에게 권한을 요청하시기 바랍니다." }, "error_status_403": { "message": "403 금지됨: 관리자에게 충분한 권한을 요청하십시오." @@ -438,7 +438,7 @@ "message": "잘못된 서버 응답입니다. Sidekick 구성 또는 URL을 확인하십시오." }, "error_view_description": { - "message": "사용자에게 친숙한 오류 메시지." + "message": "알기 쉬운 오류 메시지." }, "extensions": { "message": "확장 기능" @@ -625,7 +625,7 @@ "message": "로그아웃" }, "user_relogin": { - "message": "다시 로그인" + "message": "다시 로그인하십시오" }, "user_switch": { "message": "사용자 전환" diff --git a/src/extension/_locales/pt_BR/messages.json b/src/extension/_locales/pt_BR/messages.json index 1c10ff57a..a78a970e3 100644 --- a/src/extension/_locales/pt_BR/messages.json +++ b/src/extension/_locales/pt_BR/messages.json @@ -186,7 +186,7 @@ "message": "URL do conteúdo inválido" }, "config_invalid_org_site": { - "message": "Nome de organização ou site inválido" + "message": "Nome da organização ou site inválido" }, "config_invalid_shareurl": { "message": "URL de compartilhamento inválido" @@ -399,13 +399,13 @@ "message": "Este é um documento do Microsoft Excel. Converta-o para Planilhas Google: Arquivo > Salvar como Planilhas Google" }, "error_site_401": { - "message": "Entre para continuar." + "message": "Faça logon para continuar." }, "error_site_401_relogin": { - "message": "Acesso expirado. Entre novamente para continuar." + "message": "Acesso expirado. Faça logon novamente para continuar." }, "error_site_403": { - "message": "Acesso negado. Tente entrar com um usuário diferente ou peça permissões suficientes ao administrador." + "message": "Acesso negado. Tente fazer logon com um usuário diferente ou peça permissões suficientes à administração." }, "error_status_403": { "message": "403 Proibido: Solicite ao administrador as permissões necessárias." @@ -438,7 +438,7 @@ "message": "Resposta do servidor inválida. Verifique sua configuração Sidekick ou o URL." }, "error_view_description": { - "message": "Mensagem de erro amigável." + "message": "Mensagem de erro intuitiva." }, "extensions": { "message": "Extensões" @@ -625,7 +625,7 @@ "message": "Fazer logoff" }, "user_relogin": { - "message": "Entrar novamente" + "message": "Fazer logon novamente" }, "user_switch": { "message": "Trocar usuário" diff --git a/src/extension/_locales/zh_CN/messages.json b/src/extension/_locales/zh_CN/messages.json index e256ef1a5..802d9c56d 100644 --- a/src/extension/_locales/zh_CN/messages.json +++ b/src/extension/_locales/zh_CN/messages.json @@ -402,10 +402,10 @@ "message": "请登录以继续。" }, "error_site_401_relogin": { - "message": "访问已过期。请重新登录以继续。" + "message": "访问过期。请重新登录以继续。" }, "error_site_403": { - "message": "访问被拒绝。请尝试使用其他用户登录,或向您的管理员请求足够的权限。" + "message": "访问被拒。请尝试以其他用户身份登录或向管理员申请足够的权限。" }, "error_status_403": { "message": "403 禁止:请向管理员请求足够的权限。" @@ -438,7 +438,7 @@ "message": "服务器响应无效。检查您的 Sidekick 配置或 URL。" }, "error_view_description": { - "message": "用户友好的错误消息。" + "message": "用户友好型错误消息。" }, "extensions": { "message": "扩展" @@ -625,7 +625,7 @@ "message": "注销" }, "user_relogin": { - "message": "再次登录" + "message": "重新登录" }, "user_switch": { "message": "切换用户" diff --git a/src/extension/_locales/zh_TW/messages.json b/src/extension/_locales/zh_TW/messages.json index b7b112812..54aadcbf3 100644 --- a/src/extension/_locales/zh_TW/messages.json +++ b/src/extension/_locales/zh_TW/messages.json @@ -402,10 +402,10 @@ "message": "請登入以繼續。" }, "error_site_401_relogin": { - "message": "存取已過期。請再次登入以繼續。" + "message": "存取已到期。請重新登入以繼續。" }, "error_site_403": { - "message": "存取被拒絕。請嘗試使用其他使用者登入,或要求您的管理員提供足夠許可權。" + "message": "存取已遭拒。請嘗試使用不同的使用者登入,或向管理員要求足夠的權限。" }, "error_status_403": { "message": "403 已禁止:請向管理員要求足夠的權限。" @@ -438,7 +438,7 @@ "message": "伺服器回應無效。請檢查您的 Sidekick 設定或 URL。" }, "error_view_description": { - "message": "方便使用的錯誤訊息。" + "message": "使用者友好的錯誤訊息。" }, "extensions": { "message": "擴充功能" @@ -625,7 +625,7 @@ "message": "登出" }, "user_relogin": { - "message": "重新登入" + "message": "再次登入" }, "user_switch": { "message": "切換使用者" From 135cb50aa3385302acbc361845f21c8b8a8cfa91 Mon Sep 17 00:00:00 2001 From: Astha Bhargava Date: Tue, 24 Sep 2024 23:21:40 +0530 Subject: [PATCH 3/3] chore: fix for doc selection in localized sharepoint (#823) --- package-lock.json | 25 +++++---- package.json | 2 +- src/extension/module.js | 2 +- test/bulk-info.test.js | 53 +++++++++++++++++++ .../admin-sharepoint-chinese-grid.html | 19 +++++++ test/fixtures/admin-sharepoint-chinese.html | 26 +++++++++ 6 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 test/fixtures/admin-sharepoint-chinese-grid.html create mode 100644 test/fixtures/admin-sharepoint-chinese.html diff --git a/package-lock.json b/package-lock.json index 9b78f8525..3c0b1ffdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@adobe/eslint-config-helix": "2.0.7", - "@adobe/fetch": "4.1.8", + "@adobe/fetch": "4.1.9", "@babel/eslint-parser": "7.25.1", "@esm-bundle/chai": "4.3.4-fix.0", "@semantic-release/changelog": "6.0.3", @@ -72,13 +72,13 @@ } }, "node_modules/@adobe/fetch": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/@adobe/fetch/-/fetch-4.1.8.tgz", - "integrity": "sha512-jQ6toUlAHEMU5FqXlfyK6kcGK9Yx0+mXiqfxgH1TgNpmph8ZpAeH+8JUi0+KFN1pDPKNiO5JDLZu2GWcZPS+6Q==", + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@adobe/fetch/-/fetch-4.1.9.tgz", + "integrity": "sha512-FWIzm4vvl1OtCarTBgWDW6otj4gxrNmMf/DdriqBUw7DjjmckjT3ZQA43b4HzBkzkuAHhajwMy91btp9fWgTEw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "debug": "4.3.5", + "debug": "4.3.7", "http-cache-semantics": "4.1.1", "lru-cache": "7.18.3" }, @@ -87,13 +87,13 @@ } }, "node_modules/@adobe/fetch/node_modules/debug": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", - "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dev": true, "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -104,6 +104,13 @@ } } }, + "node_modules/@adobe/fetch/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", diff --git a/package.json b/package.json index 34140c8c5..b1f60a8e3 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@adobe/eslint-config-helix": "2.0.7", - "@adobe/fetch": "4.1.8", + "@adobe/fetch": "4.1.9", "@babel/eslint-parser": "7.25.1", "@esm-bundle/chai": "4.3.4-fix.0", "@semantic-release/changelog": "6.0.3", diff --git a/src/extension/module.js b/src/extension/module.js index b9b1bd1c4..36120716a 100644 --- a/src/extension/module.js +++ b/src/extension/module.js @@ -1762,7 +1762,7 @@ import sampleRUM from './rum.js'; .map((row) => { const info = row.getAttribute('aria-label') || row.querySelector('span')?.textContent; // info format: bla.docx, docx File, Private, Modified 8/28/2023, edited by Jane, 1 KB - const type = info.match(/, ([a-z0-9]+) [A-Za-z]+,/)?.[1]; + const type = info.match(/, ([\p{L}\p{N}]+) [\p{L}\p{N}]+,/u)?.[1]; const path = type && info.split(`, ${type}`)[0]; return { path, diff --git a/test/bulk-info.test.js b/test/bulk-info.test.js index 3ba39224a..3c44ed506 100644 --- a/test/bulk-info.test.js +++ b/test/bulk-info.test.js @@ -102,7 +102,60 @@ describe('Test bulk info plugin', () => { return Number.isNaN(num) ? false : num === 2; }), }).run(); + assert.ok(sizeCheck, 'Wrong selection size displayed'); }).timeout(IT_DEFAULT_TIMEOUT); }); + + it('Bulk info plugin displays selection size in non-latin sharepoint', async () => { + const { setup } = TESTS[0]; + const fixture = 'admin-sharepoint-chinese.html'; + nock.sidekick(); + nock.admin(setup, { + route: 'status', + type: 'admin', + }); + const { checkPageResult: sizeCheck } = await new SidekickTest({ + browser, + page, + fixture, + url: setup.getUrl('edit', 'admin'), + loadModule: true, + checkPage: (p) => p.evaluate(() => { + // get displayed selection size + const info = window.hlx.sidekick.shadowRoot.getElementById('hlx-sk-bulk-info'); + const num = +(info.textContent + .split(' ') + .shift()); + return Number.isNaN(num) ? false : num === 1; + }), + }).run(); + assert.ok(sizeCheck, 'Wrong selection size displayed'); + }).timeout(IT_DEFAULT_TIMEOUT); + + it('Bulk info plugin displays selection size in non-latin sharepoint grid', async () => { + const { setup } = TESTS[0]; + const fixture = 'admin-sharepoint-chinese-grid.html'; + nock.sidekick(); + nock.admin(setup, { + route: 'status', + type: 'admin', + }); + const { checkPageResult: sizeCheck } = await new SidekickTest({ + browser, + page, + fixture, + url: setup.getUrl('edit', 'admin'), + loadModule: true, + checkPage: (p) => p.evaluate(() => { + // get displayed selection size + const info = window.hlx.sidekick.shadowRoot.getElementById('hlx-sk-bulk-info'); + const num = +(info.textContent + .split(' ') + .shift()); + return Number.isNaN(num) ? false : num === 1; + }), + }).run(); + assert.ok(sizeCheck, 'Wrong selection size displayed'); + }).timeout(IT_DEFAULT_TIMEOUT); }); diff --git a/test/fixtures/admin-sharepoint-chinese-grid.html b/test/fixtures/admin-sharepoint-chinese-grid.html new file mode 100644 index 000000000..73c92d7fa --- /dev/null +++ b/test/fixtures/admin-sharepoint-chinese-grid.html @@ -0,0 +1,19 @@ + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/test/fixtures/admin-sharepoint-chinese.html b/test/fixtures/admin-sharepoint-chinese.html new file mode 100644 index 000000000..aab5657c8 --- /dev/null +++ b/test/fixtures/admin-sharepoint-chinese.html @@ -0,0 +1,26 @@ + + + + + +
+
+
+ + +
+
+ + + + +
+
+ + +
+
+
+ + + \ No newline at end of file