XWiki Commons
  1. XWiki Commons
  2. XCOMMONS-494

NPE in $escapetool.url() if a parameter is null

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.3-milestone-1
    • Fix Version/s: 5.3-milestone-2, 5.2.2
    • Component/s: Velocity
    • Labels:
      None
    • Tests:
      Unit
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      The following Velocity code fails with a NullPointerException:

      $escapetool.url({
        'foo': $null
      })
      

        Activity

        Hide
        Marius Dumitru Florea added a comment -

        The question is what should the following code generate:

        $escapetool.url({
          'foo': $null,
          'bar': ['one', $null, 'three'],
          $null: 'value'
        })
        

        There are a few options:

        1. Skip null parameter key and value
          bar=one&bar=three
          
        2. Use 'null' for both the key and the value
          foo=null&bar=one&bar=null&bar=three&null=value
          
        3. Use empty string for null value
          foo=&bar=one&bar=&bar=three&null=value
          

        I prefer (1).

        Show
        Marius Dumitru Florea added a comment - The question is what should the following code generate: $escapetool.url({ 'foo': $null, 'bar': ['one', $null, 'three'], $null: 'value' }) There are a few options: Skip null parameter key and value bar=one&bar=three Use 'null' for both the key and the value foo=null&bar=one&bar=null&bar=three&null=value Use empty string for null value foo=&bar=one&bar=&bar=three&null=value I prefer (1).
        Hide
        Marius Dumitru Florea added a comment -

        In the end I followed Sergiu's preference for:

        • Skip parameters without name (null key)
        • Serialize null values as an empty string
        foo=&bar=one&bar=&bar=three
        
        Show
        Marius Dumitru Florea added a comment - In the end I followed Sergiu's preference for: Skip parameters without name (null key) Serialize null values as an empty string foo=&bar=one&bar=&bar=three

          People

          • Assignee:
            Marius Dumitru Florea
            Reporter:
            Marius Dumitru Florea
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: