Skip to content

Add guard for undefined value in getEmoji

euko requested to merge fix-gl-emoji-undefined-value into master

What does this MR do?

This MR fixes a regression introduced in !42669 (merged) which causes the following console error in issue list page. image

what causes the console error?

gl-emoji is a web component for displaying an emoji. Here's an example usage:

 `<gl-emoji data-name="star" ...>`.

Using the data-name attribute, gl-emoji initializes its emoji info using getEmojiInfo function from ~/emoji/index.js:

// gl_emoji.js#L16: "name" comes from "data-name"
        const emojiInfo = getEmojiInfo(name); 

When data-name is not supplied (so input is undefined), getEmojiInfo used to return a fallback emoji prior to !42669 (merged). After !42669 (merged), getEmojiInfo doesn't directly return a fallback value but rather let other functions(getEmoji/searchEmoji) deal with undefined input and toLowerCase() ends up getting called on undefined.

This MR adds a check for undefined in getEmoji/searchEmoji so that these can return null. We should follow up to restore the fallback behavior that was in place before !42669 (merged) - (tracked in #268208 (closed))

when and why is gl-emoji used without data-name attribute?

In the filtered search bar in issue list, we pre-load gl-emoji components _search_bar.html.haml#L139 without data attributes in the background.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by euko

Merge request reports

Loading