This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-post.git


The following commit(s) were added to refs/heads/master by this push:
     new 326753e   SLING-2534 : Strings of zero length on update in post 
servlet delete the property. Apply patch from Hanish Bansal
326753e is described below

commit 326753eddfa7565b7a223fa9bc63c7aa78c33ce0
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Tue Dec 18 14:59:26 2018 +0100

     SLING-2534 : Strings of zero length on update in post servlet delete the 
property. Apply patch from Hanish Bansal
---
 .../servlets/post/impl/helper/SlingPropertyValueHandler.java  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
 
b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
index 2530647..11a77a0 100644
--- 
a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
+++ 
b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
@@ -209,14 +209,13 @@ public class SlingPropertyValueHandler {
 
         String[] values = prop.getStringValues();
 
-        if (values == null
-                || (values.length == 1 && values[0].length() == 0 && 
getType(parent, prop) != PropertyType.STRING)) {
-            // if no value is present or a single empty non string is given,
-            // just remove the existing property (if any)
+        // RequestProperty#getStringValues already takes care of the configs 
ignoreBlanks, defaultValues etc.
+        // and provides values as null, new String[0] etc. accordingly.
+        if (values == null) {
+            // if no value is present, just remove the existing property (if 
any)
             removeProperty(parent, prop);
 
-        } else if (values.length == 0
-                || (values.length == 1 && values[0].length() == 0 && 
getType(parent, prop) == PropertyType.STRING)) {
+        } else if (values.length == 0) {
             // do not create new prop here, but clear existing
             clearProperty(parent, prop);
 

Reply via email to