Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Added replacer to avoid 10e in node-names #91

Merged
merged 1 commit into from
Aug 5, 2016

Conversation

wachterjohannes
Copy link
Member

This PR avoids 10e in node names by replacing it. This replaces sulu/sulu#2387 .

@@ -196,6 +196,9 @@ private function getName(AutoNameBehavior $document, NodeInterface $parentNode,

$name = $this->slugifier->slugify($title);

// jackrabbit can not handle node-names which contains a number followed by "e" e.g. 10e
$name = preg_replace('((\d+)e)', '$1-e', $name);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think in my analysis at jackalope/jackalope#313 i found that only .-% before a number trigger the problem. and that uppercase E is also a problem. maybe '([\.-%]\d+)([eE])', '$1-$2 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats right (: i will change it to this regex. thanks for your feedback

Copy link

@dbu dbu Jun 9, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu
Copy link

dbu commented Jun 9, 2016

can the user ever manually define node names? or does that also go through this auto-namer? you might want to un-escape when loading, unless the names are never publicly visible (not even in api calls). if you do, you should replace (\d)+(-+)([eE]) by $1$2-$3 and always remove one - so that names that would need no escaping are not mangled.

@wachterjohannes
Copy link
Member Author

@dbu all nodes which we use for querying is generated by this auto-name behavior. i don't think we want to undo this for the user because if he want to use this path it should be valid.

@danrot
Copy link
Contributor

danrot commented Jul 12, 2016

The JIRA issue is https://issues.apache.org/jira/browse/JCR-3985, just putting it here for reference.

@danrot
Copy link
Contributor

danrot commented Jul 12, 2016

This error also happens for .10e and only 10e, but the regex doesn't cover these. I guess when it comes to the regex they are both the same, because the . is probably removed before.

@danrot danrot modified the milestone: Release 1.3 Jul 12, 2016
@dbu
Copy link

dbu commented Jul 12, 2016 via email

@wachterjohannes
Copy link
Member Author

@danrot most of the cases should be covered because . or , will be replaced by a - so they wont ma a problem there. i have tested now multiple formats and i have not found any which causes this problem ...

@danrot
Copy link
Contributor

danrot commented Jul 25, 2016

The problem is that the . doesn't come to the regex, at least that is my guess. And just calling a site 10e also didn't work, which makes sense, since the regex says that there has to be something before 10e.

@wachterjohannes wachterjohannes force-pushed the hotfix/avoid-10e-node-names branch 3 times, most recently from f490475 to 3fb04b2 Compare July 26, 2016 11:43
@wachterjohannes
Copy link
Member Author

@danrot fixed

=======
* dev-master
* HOTFIX #91 Added replacer to avoid 10e in node-names
>>>>>>> added replacer to avoid 10e in node-names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please solve that merge conflict 😃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha (: seems that i need glasses

@wachterjohannes
Copy link
Member Author

@danrot now everything should be fine

*/


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two additions were not here before, were they? Both of them should be removed, same for the other file.

@danrot
Copy link
Contributor

danrot commented Jul 27, 2016

And can you please rebase the branch and remove the merge commit? 😃

@danrot danrot added this to the Release 1.3 milestone Jul 28, 2016
@danrot danrot added the Bug label Jul 28, 2016
@chirimoya
Copy link
Member

ping @wachterjohannes

@wachterjohannes wachterjohannes force-pushed the hotfix/avoid-10e-node-names branch 2 times, most recently from fc15a9f to 86bcb12 Compare August 5, 2016 05:31
@wachterjohannes
Copy link
Member Author

@danrot rebased

@@ -199,6 +200,9 @@ private function getName(

$name = $this->slugifier->slugify($title);

// jackrabbit can not handle node-names which contains a number followed by "e" e.g. 10e
$name = preg_replace('(([\.%-]?\d+)([eE]))', '$1-$2', $name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first part of the regex [\.%-]? could be removed now, since it matches everytime. The ? modifier says that it can occur, but doesn't have to. If we really want to make this happen only when there is a ., %, - or nothing in front of it the regex gets more complicated, and I don't know if it is worth it 😕

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants