From 82ea8ea68cabdeea9d89a24965fd886d9233181e Mon Sep 17 00:00:00 2001 From: SushiJackal <51118771+SushiJackal@users.noreply.github.com> Date: Tue, 6 Apr 2021 01:50:39 +0200 Subject: [PATCH] fix: reject task append to JumpList when description exceeds 260 characters (#28485) * fix: reject task when description exceeds 260 characters * Switched out wcslen() for size() [linear -> constant time] * Included comment describing the need for the additional check * Added information about character limit to documentation * Added newline character to end of jump-list-category.md --- docs/api/app.md | 4 ++++ docs/api/structures/jump-list-category.md | 4 ++++ docs/api/structures/jump-list-item.md | 2 +- shell/browser/ui/win/jump_list.cc | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/api/app.md b/docs/api/app.md index 9bafce2dc19..e87bc13d56e 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -871,6 +871,10 @@ re-add a removed item to a custom category earlier than that will result in the entire custom category being omitted from the Jump List. The list of removed items can be obtained using `app.getJumpListSettings()`. +**Note:** The maximum length of a Jump List item's `description` property is +260 characters. Beyond this limit, the item will not be added to the Jump +List, nor will it be displayed. + Here's a very simple example of creating a custom Jump List: ```javascript diff --git a/docs/api/structures/jump-list-category.md b/docs/api/structures/jump-list-category.md index 07627e78c98..0f27f2085f6 100644 --- a/docs/api/structures/jump-list-category.md +++ b/docs/api/structures/jump-list-category.md @@ -19,3 +19,7 @@ property set then its `type` is assumed to be `tasks`. If the `name` property is set but the `type` property is omitted then the `type` is assumed to be `custom`. + +**Note:** The maximum length of a Jump List item's `description` property is +260 characters. Beyond this limit, the item will not be added to the Jump +List, nor will it be displayed. diff --git a/docs/api/structures/jump-list-item.md b/docs/api/structures/jump-list-item.md index d75637cb472..491abf80d30 100644 --- a/docs/api/structures/jump-list-item.md +++ b/docs/api/structures/jump-list-item.md @@ -17,7 +17,7 @@ * `title` String (optional) - The text to be displayed for the item in the Jump List. Should only be set if `type` is `task`. * `description` String (optional) - Description of the task (displayed in a tooltip). - Should only be set if `type` is `task`. + Should only be set if `type` is `task`. Maximum length 260 characters. * `iconPath` String (optional) - The absolute path to an icon to be displayed in a Jump List, which can be an arbitrary resource file that contains an icon (e.g. `.ico`, `.exe`, `.dll`). You can usually specify `process.execPath` to diff --git a/shell/browser/ui/win/jump_list.cc b/shell/browser/ui/win/jump_list.cc index ecea78b1fae..44af44e44df 100644 --- a/shell/browser/ui/win/jump_list.cc +++ b/shell/browser/ui/win/jump_list.cc @@ -28,6 +28,13 @@ bool AppendTask(const JumpListItem& item, IObjectCollection* collection) { FAILED(link->SetDescription(item.description.c_str()))) return false; + // SetDescription limits the size of the parameter to INFOTIPSIZE (1024), + // which suggests rejection when exceeding that limit, but experimentation + // has shown that descriptions longer than 260 characters cause a silent + // failure, despite SetDescription returning the success code S_OK. + if (item.description.size() > 260) + return false; + if (!item.icon_path.empty() && FAILED(link->SetIconLocation(item.icon_path.value().c_str(), item.icon_index)))