Skip to content

Clean note filename. #196

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

Merged
merged 1 commit into from
Apr 6, 2016
Merged

Conversation

slashrsm
Copy link
Contributor

Removes unwanted characters from the note's filename.

Fixes #167

@slashrsm slashrsm changed the title #167: Clean note filename. Clean note filename. Jan 25, 2016
@abyssox
Copy link

abyssox commented Feb 14, 2016

What about german umlaute? They would be replaced by an underscore too.
In german we have the ability to replace them with "ae", "oe" and "ue". Like this:

$search = array("Ä", "Ö", "Ü", "ä", "ö", "ü"); $replace = array("Ae", "Oe", "Ue", "ae", "oe", "ue"); $title = str_replace($search, $replace, $title);

@suhr
Copy link

suhr commented Feb 19, 2016

What about non-latin letters like cyrillic?

@jancborchardt
Copy link
Member

@slashrsm I wouldn’t necessarily go so far just to fix #167. The one specific problem we really have is the one of leading # (hash and a space, or no space) in the title, because of markdown. That we should remove, but other characters we should leave for now.

Because as the others mentioned too – why would you want to replace umlaute and other characters, dashes etc?

Also, the underscore should never ever be in a filename. It is an ugly character only meant for underlining back in the typewriter days. Doesn’t look nice but only technical in filenames.

@slashrsm
Copy link
Contributor Author

Updated based on what @jancborchardt suggested. Thank you for the input.

@@ -112,6 +112,9 @@ public function update ($id, $content, $userId){

// prevent directory traversal
$title = str_replace(array('/', '\\'), '', $title);
// remove hash and space characters from the beginning of the filename
// in case of markdown
$title = ltrim($title, ' #');
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn’t it be #(space) instead of (space)#? And also ideally trim just the plain # as well in case someone doesn’t put a space behind the hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ltrim() will trim any character in the character list. Order is not important. "# foo", " #foo", "#foo", " foo", " foo" will all end up as "foo" after this gets executed.

Copy link
Member

Choose a reason for hiding this comment

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

Ah cool, thanks for the info! :)

@jancborchardt
Copy link
Member

See my inline comment. :) Also @Henni @BernhardPosselt please check,

@slashrsm when you’re done, can you please squash your commits into one so we have a clean history? Thanks! :)

@slashrsm slashrsm force-pushed the transliterate_name branch from 53b2bc2 to c04d550 Compare March 22, 2016 10:22
@slashrsm
Copy link
Contributor Author

@jancborchardt Thank you for your feedback. Commits squashed.

@jancborchardt
Copy link
Member

I can’t really review the code but it looks good.

@suhr @calis2002 @Henni @LukasReschke @BernhardPosselt can you check it out?

@slashrsm
Copy link
Contributor Author

slashrsm commented Apr 6, 2016

Any thoughts on this?

@jancborchardt
Copy link
Member

Can you please review this @MorrisJobke @stefan-niedermann @Henni @suhr @calis2002 @LukasReschke

@LukasReschke LukasReschke merged commit 2c27d6e into owncloud:master Apr 6, 2016
@LukasReschke
Copy link
Member

Thank you. Works fine 🚀

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

Successfully merging this pull request may close these issues.

5 participants