Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25219

BaseObject#set throws a NullPointerException when setting an existing password property to the form placeholder

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      • Have an XClass with a Password property, and an object of that class where the password is already set
      • Call $obj.set('password', '********') (e.g. the placeholder value sent back by a form displaying the password field in edit mode)

      Expected

      The existing password value is kept, as it was before 17.9.0RC1.

      Actual

      java.lang.NullPointerException: Cannot invoke "com.xpn.xwiki.objects.BaseProperty.getValue()" because "newProp" is null
       at com.xpn.xwiki.objects.BaseObject.set(BaseObject.java:522)
       at com.xpn.xwiki.api.Object.set(Object.java:206)
      

      Analysis

      PasswordClass#fromString deliberately returns null when given the form password placeholder, so that the stored password is not replaced by it. Before XWIKI-21417, BaseObject#set assigned the result of fromString to the property and skipped it when null, so the existing value was kept. Since XWIKI-21417, BaseObject#set updates the existing property in place with prop.setValue(newProp.getValue()), without checking whether newProp is null.

      The null returned by fromString should be handled as "keep the current value".

      This breaks for example the JIRA Macro basic auth configuration as soon as a second entry is saved: JIRA-126.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: