Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-20202

Fix potential NPE in nuxeo-select2.js

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.8.0-HF36
    • Fix Version/s: 5.8.0-HF41
    • Component/s: Seam / JSF UI
    • Tags:
    • Backlog priority:
      600
    • Sprint:
      nxFG 8.4.2

      Description

      NXP-17807 introduces this error.

      This can be fixed by using the code from recent version

      diff --git a/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js b/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      index 820f703..2fa4ddc 100644
      --- a/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      +++ b/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      @@ -1,8 +1,18 @@
       (function() {
       
      +  var entityMap = {
      +          '&': '&',
      +          '<': '&lt;',
      +          '>': '&gt;',
      +          '"': '&quot;',
      +          "'": '&#39;',
      +          '/': '&#x2F;'
      +        };
      +
         function escapeHTML(string) {
      -    // prototype.js allows us to use escapeHTML on strings
      -    return string.escapeHTML();
      +      return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) {
      +          return entityMap[s];
      +      });
         }
      

      or by checking if the string is null

      diff --git a/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js b/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      index 820f703..d1a2639 100644
      --- a/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      +++ b/nuxeo-features/nuxeo-platform-ui-select2/src/main/resources/web/nuxeo.war/scripts/select2/nuxeo-select2.js
      @@ -1,6 +1,9 @@
       (function() {
       
         function escapeHTML(string) {
      +    if (string == null) {
      +      return string;
      +    }
           // prototype.js allows us to use escapeHTML on strings
           return string.escapeHTML();
         }
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h