Permalink
Browse files

Fix buggy handling of author's names with international characters

git-svn-id: http://plugins.svn.wordpress.org/feedwordpress/trunk@25113 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information...
1 parent 43bbca4 commit 3ba557118e92657cff64d3d58244d06a102d2f2c radgeek committed Nov 22, 2007
Showing with 15 additions and 4 deletions.
  1. +15 −4 wp-content/plugins/feedwordpress/feedwordpress.php
@@ -226,6 +226,11 @@ function current_user_can ($task) {
} else {
$legacy_capability_hack = false;
}
+if (!function_exists('sanitize_user')) {
+ function sanitize_user ($text, $strict) {
+ return $text; // Don't munge it if it wasn't munged going in...
+ }
+}
################################################################################
## TEMPLATE API: functions to make your templates syndication-aware ############
@@ -2333,7 +2338,12 @@ function author_id ($unfamiliar_author = 'create') {
$url = $a['uri'];
// Never can be too careful...
+ $login = sanitize_user($author, /*strict=*/ true);
+ $login = apply_filters('pre_user_login', $login);
+
$nice_author = sanitize_title($author);
+ $nice_author = apply_filters('pre_user_nicename', $nice_author);
+
$reg_author = $wpdb->escape(preg_quote($author));
$author = $wpdb->escape($author);
$email = $wpdb->escape($email);
@@ -2345,7 +2355,7 @@ function author_id ($unfamiliar_author = 'create') {
$id = $wpdb->get_var(
"SELECT ID from $wpdb->users
WHERE
- TRIM(LCASE(user_login)) = TRIM(LCASE('$author')) OR
+ TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
(
LENGTH(TRIM(LCASE(user_email))) > 0
AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
@@ -2370,7 +2380,7 @@ function author_id ($unfamiliar_author = 'create') {
$id = $wpdb->get_var(
"SELECT ID FROM $wpdb->users
WHERE
- TRIM(LCASE(user_login)) = TRIM(LCASE('$author'))
+ TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
OR (
LENGTH(TRIM(LCASE(user_email))) > 0
AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
@@ -2405,7 +2415,7 @@ function author_id ($unfamiliar_author = 'create') {
"INSERT INTO $wpdb->users
SET
ID='0',
- user_login='$author',
+ user_login='$login',
user_firstname='$author',
user_nickname='$author',
user_nicename='$nice_author',
@@ -2419,7 +2429,8 @@ function author_id ($unfamiliar_author = 'create') {
#-- user table data
$userdata['ID'] = NULL; // new user
- $userdata['user_login'] = $author;
+ $userdata['user_login'] = $login;
+ $userdata['user_nicename'] = $nice_author;
$userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6); // just something random to lock it up
$userdata['user_email'] = $email;
$userdata['user_url'] = $url;

0 comments on commit 3ba5571

Please sign in to comment.