Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-26276: Exclamation mark followed by non-chars at end of URL does not work in emails #1260

Merged
merged 1 commit into from
Sep 20, 2016
Merged

Conversation

gabrielfin
Copy link
Contributor

@gabrielfin gabrielfin commented Sep 8, 2016

Fix for https://jira.ez.no/browse/EZP-14719 (old zombie issue)
https://jira.ez.no/browse/EZP-26276 (new incarnation)

This is "My Article!" becomes This-is-My-Article!. The exclamation mark should not be there.

@yannickroger
Copy link
Contributor

ping @glye it looks like this one came back from the dead to eat your brain 😄

@glye
Copy link
Member

glye commented Sep 9, 2016

@gabrielfin Thanks. Which version(s) does this affect?

Note that we need a different approach to make this complete. The PR as is fixes the case of This is "My Article!" but just to be difficult, let's try these ;)
This is "My Article!"!" -> This-is-My-Article!
This is "My Article!"!"!" -> This-is-My-Article!-!
So we need either smarter regexps here, or a loop.

And this fix in commandUrlCleanup should probably be duplicated in commandUrlCleanupIRI below.

@glye glye changed the title EZP-14719: Exclamation mark at end of URL does not work in emails EZP-26276: Exclamation mark followed by non-chars at end of URL does not work in emails Sep 9, 2016
@glye
Copy link
Member

glye commented Sep 9, 2016

FYI I made a new issue, and updated the title/description.

@gabrielfin
Copy link
Contributor Author

gabrielfin commented Sep 9, 2016

This issue affects, at least, master and 4.2.0. But I guess it actually affects every legacy version since the original patch (EZP-14719).

How about if "Remove dots at beginning/end" actually strips them instead of replacing them with $sep, and we add {$sepQ} to the second bracket expression. ie:

        $text = preg_replace( array( "#[^a-zA-Z0-9_!\.-]+#",
                                     "#^[\.]+|[!\.{$sepQ}]+$#", # Remove dots at beginning/end
                                     "#\.\.+#", # Remove double dots
                                     "#[{$sepQ}]+#", # Turn multiple separators into one
                                     "#^[{$sepQ}]+|[{$sepQ}]+$#" ), # Strip separator from beginning/end
                              array( $sep,
                                     "",
                                     $sep,
                                     $sep,
                                     "" ),
                              $text );

Perhaps this new regex could also be merged with the last regex.

@glye
Copy link
Member

glye commented Sep 12, 2016

@gabrielfin That sounds ok to me.

@gabrielfin
Copy link
Contributor Author

gabrielfin commented Sep 12, 2016

I updated the PR with the proposed regex. I also merged it with the last regex, since they were actually very similar and it also fixes an additional test case: dot preceded by a non char at the beginning of the url (ie ".My Article" turned (wrongly) into .My-Article)

I also applied the same to commandUrlCleanupIRI.

On a sidenote: the usage of $prepost seems unnecessary. It strips trailing spaces, which were already stripped, and it strips trailing dashes when dash is not the separator (why?). However, I just left it as is.

@glye
Copy link
Member

glye commented Sep 16, 2016

+1, works in my test.
@yannickroger, you want to have a look again? :)

@yannickroger
Copy link
Contributor

I had a look, it's full of regular expressions 😄
but +1

@glye
Copy link
Member

glye commented Sep 20, 2016

Note: This does not strip exclamation marks from the beginning of strings, but the original didn't do that either.

@glye glye merged commit 6e625be into ezsystems:master Sep 20, 2016
@glye
Copy link
Member

glye commented Sep 20, 2016

Merged. Thanks @gabrielfin!

petrmifek added a commit to petrmifek/ezpublish-legacy that referenced this pull request May 23, 2017
* master: (40 commits)
  A quick hack to support html entities in RSS imported item descriptions.
  Fix EZP-27321: Update TinyMCE to 3.5.12 and patch for "Uncaught DOMEx… (ezsystems#1297)
  EZP-27011: Solr index not updated when changing a content priority (ezsystems#1283)
  EZP-15983 - Only include ezp_override when present (ezsystems#1270)
  Add state change/assign to the audit log (ezsystems#1285)
  EZP-27092: Remove eZAutoLink operator usage of preg_replace and PREG_REPLACE_EVAL (ezsystems#1286)
  Fix EZP-26911: Embedded PDF files are downloadable though they are in trash
  EZP-27000: Remove uploader.swf from all repos/branches
  Fix EZP-26659: The package component is vulnerable to arbitrary file upload
  Fix EZP-26405: SQL Injection in Search Component (ezsearchengine)
  Setting to have different cache based on the request protocol
  Fix EZP-26832: Enabling editor causes error on links with "&" (ezsystems#1278)
  Making sure all affected PHP versions are handled
  Fix EZP-26798: Query parameters get lost when being redirected with mobile device detect filter
  Fix EZP-26405: SQL Injection in Search Component (ezsearchengine) (ezsystems#105)
  Fix EZP-26449: Wrong version translation list in eZContentOperationCollection
  Fix EZP-26427: ezoe popup search string not urlencoded
  Fix EZP-26354: Autolink fails if you try to link content in your own site (ezsystems#1263)
  Fix EZP-25031: eZContentUpload is not providing original file name to custom UploadHandler (ezsystems#1228)
  Fix EZP-26276: Exclamation mark followed by non-chars at end of URL does not work in emails (ezsystems#1260)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants