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

Town News: Try to avoid using email as display name for authors #374

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

naxoc
Copy link
Member

@naxoc naxoc commented Nov 3, 2023

I noticed that we can risk creating slugs with emails. This does some string juggling to avoid that.

How to test

  • Run the migration and verify that guest users are created with whatever is before the '@' if there is only an email on them.

@naxoc naxoc requested a review from a team November 3, 2023 16:21
@naxoc naxoc self-assigned this Nov 3, 2023
@@ -696,7 +698,7 @@ private function set_post_author( $post_id, $display_name, $author_meta, $defaul
);
} else {
// Set as a co-author.
$guest_author = $this->coauthorsplus_logic->get_guest_author_by_user_login( $email );
$guest_author = $this->coauthorsplus_logic->get_guest_author_by_user_login( $display_name );
Copy link
Contributor

Choose a reason for hiding this comment

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

Using $email was a bug here, nice catch! The create_guest_author used here to create a new co-author uses the sanitized display_name as user_login in case we don't provide the later, so I think to fetch co-authors using $display_name as user_login we should pass the sanitized version.

Suggested change
$guest_author = $this->coauthorsplus_logic->get_guest_author_by_user_login( $display_name );
$guest_author = $this->coauthorsplus_logic->get_guest_author_by_user_login( sanitize_title( $display_name ) );

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Zak - good catch!

I added sanitization with sanitize_user because I assume that is what the user login is run through when it's created. Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

The user is created as of now with sanitize_title, but I think it's better to fix it properly and change it there to sanitize_user

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I moved the sanitization around a bit to make it more consistent.

@naxoc
Copy link
Member Author

naxoc commented Nov 10, 2023

I also added tag stripping in bylines – I had a couple of files where the byline was dirty.

@naxoc
Copy link
Member Author

naxoc commented Jan 8, 2024

@kariae This one got a bit old. I'm not sure if it is still relevant. What do you think?

@naxoc
Copy link
Member Author

naxoc commented May 8, 2024

@kariae I think this one can just be closed with no merge. It's so old :) What do you think?

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

Successfully merging this pull request may close these issues.

None yet

2 participants