You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Alex Parvulescu (JIRA)" <ji...@apache.org> on 2012/06/04 21:00:24 UTC
[jira] [Created] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Alex Parvulescu created SLING-2502:
--------------------------------------
Summary: Incorrect escaping of property names in JcrModifiablePropertyMap on save
Key: SLING-2502
URL: https://issues.apache.org/jira/browse/SLING-2502
Project: Sling
Issue Type: Bug
Components: JCR
Affects Versions: JCR Resource 2.1.0
Reporter: Alex Parvulescu
This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
The regression happens for properties that have ":" in the name.
For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295048#comment-13295048 ]
Carsten Ziegeler commented on SLING-2502:
-----------------------------------------
You can call getNamespaceURI(prefix) on the jcr session, if that works, the prefix exists. If it throws a NamespaceException, the prefix doesn't exist
Not nice, I agree, but it should do the trick
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Carsten Ziegeler reassigned SLING-2502:
---------------------------------------
Assignee: Carsten Ziegeler
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Assignee: Carsten Ziegeler
> Attachments: SLING-2502-v2.patch, SLING-2502-v3.patch, SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Carsten Ziegeler resolved SLING-2502.
-------------------------------------
Resolution: Fixed
Fix Version/s: JCR Resource 2.1.2
Again, many thanks for your patch. Looks good :) I've applied it to latest svn trunk.
Thanks
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Assignee: Carsten Ziegeler
> Fix For: JCR Resource 2.1.2
>
> Attachments: SLING-2502-v2.patch, SLING-2502-v3.patch, SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13294914#comment-13294914 ]
Alex Parvulescu commented on SLING-2502:
----------------------------------------
any updates on this issue?
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Carsten Ziegeler updated SLING-2502:
------------------------------------
Attachment: org.apache.sling.jcr.resource.patch
Some test testing a jcr:title property (which currently fail)
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Parvulescu updated SLING-2502:
-----------------------------------
Attachment: SLING-2502-v2.patch
attached update patch base on feedback from Carsten and Julian.
It also includes Carsten's patch.
I basically added a new method: escapeKeyName that is also used in the #get method.
all the tests pass.
feedback welcome!
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502-v2.patch, SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295055#comment-13295055 ]
Julian Reschke commented on SLING-2502:
---------------------------------------
There's also Session.getNamespacePrefixes(), returning a String array.
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295067#comment-13295067 ]
Alex Parvulescu commented on SLING-2502:
----------------------------------------
aha, I stand corrected :)
getNode().getSession().getNamespacePrefixes() returns all the available prefixes [sling, jcr, , nt, sv, xs, xml, fn_old, fn, mix, rep]
thanks Julian
stand by for an updated patch
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Parvulescu updated SLING-2502:
-----------------------------------
Attachment: SLING-2502-v3.patch
even simpler then ;)
attached new patch, plus a new property in the test "jcr:"
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502-v2.patch, SLING-2502-v3.patch, SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295129#comment-13295129 ]
Carsten Ziegeler commented on SLING-2502:
-----------------------------------------
Thanks for the patch, Alex!
Looks basically good with one exception :) I guess if the property is just a registered prefix followed by a colon, this is an invalid name as well. So the prefix searching is only necessary if there is a colon and if the key has characters after the colon.
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502-v2.patch, SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13289217#comment-13289217 ]
Carsten Ziegeler commented on SLING-2502:
-----------------------------------------
Good catch!
I think, the right way would be to modify the save() method to check whether a property name is allowed or not:
- if it has a colon, check if the prefix is known - if so check if any other character needs escaping
- if the prefix is unknown, to full escaping as is
The clear method clears the whole map which means all properties need to be removed, that's why all keys are added
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (SLING-2502) Incorrect escaping of property names
in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Parvulescu updated SLING-2502:
-----------------------------------
Attachment: SLING-2502.patch
I'm taking a stab at this: I'm introducing a new set that only contains the new properties.
I'm assuming that the existing properties don't really need to be escaped again, as they passed the check before.
See also [0]:
{quote}
Once the node exists, its name just needs to be passed around, but no escaping should happen for accessing the node, since it will already be in the right form
{quote}
This will fix a part of the problem: it handles updating properties that contain ":" like jcr:title, jcr:lastModified and friends.
It doesn't however, handle adding properties that fall into this category.
Minor issue:
Not sure yet why the #clear() method re-initializes the changedProperties set:
{code}
this.changedProperties.addAll(this.cache.keySet());
{code}
Attaching proposed patch.
[0] http://wiki.apache.org/jackrabbit/EncodingAndEscaping
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295045#comment-13295045 ]
Alex Parvulescu commented on SLING-2502:
----------------------------------------
thanks Carsten for the feedback.
I wasn't aware that the ball was in my court :)
Your test fails as expected, see my previous comment:
> This will fix a part of the problem: it handles updating properties that contain ":" like jcr:title, jcr:lastModified and friends.
It doesn't however, handle adding properties that fall into this category.
...and the test adds a new property, which is not covered by the provided patch.
I agree that generally a patch has to cover everything, but the initial patch was just meant to get things going a bit.
It also serves as a quick fix for applications that use this map for updates, not for new properties (read CQ Find and Replace)
wrt your proposal:
> - if it has a colon, check if the prefix is known - if so check if any other character needs escaping
this is a tricky one: how do you know if a prefix is known? I'd have to have access to the registered node types, which you don't in this map.
Here I'm not talking about the classics: jcr & sling, I'm mostly referring to "cq" and friends ;)
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (SLING-2502) Incorrect escaping of property
names in JcrModifiablePropertyMap on save
Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13294990#comment-13294990 ]
Carsten Ziegeler commented on SLING-2502:
-----------------------------------------
I just tested your patch and while it passes your test, it doesn't pass the one I attached :)
I think, the implementation has to be changed in the way I described on 05/Jun/12 07:38
> Incorrect escaping of property names in JcrModifiablePropertyMap on save
> ------------------------------------------------------------------------
>
> Key: SLING-2502
> URL: https://issues.apache.org/jira/browse/SLING-2502
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR Resource 2.1.0
> Reporter: Alex Parvulescu
> Attachments: SLING-2502.patch, org.apache.sling.jcr.resource.patch
>
>
> This follows SLING-2425 where there was a change in the way JCR properties are escaped before being persited.
> The regression happens for properties that have ":" in the name.
> For example: jcr:title after the #save() call will turn into jcr%3Atitle so the node will end up with a brand new property, instead of having the old jcr:title updated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira