From 3fb4b92cd6ed09555c558cab7e33c3df988a7bfe Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 21 Feb 2011 15:01:57 -0800 Subject: [PATCH] Fix ticket #3001: Twitter bridge was replacing original form of @-mentions with canonical form unexpectedly Now using the original text form of @-mentions and #-tags, as in Twitter's own HTMLification. Canonical forms are still used in generating links, where it's polite to match the canonical form. --- plugins/TwitterBridge/twitterimport.php | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/plugins/TwitterBridge/twitterimport.php b/plugins/TwitterBridge/twitterimport.php index 475a99efac..2067196d36 100644 --- a/plugins/TwitterBridge/twitterimport.php +++ b/plugins/TwitterBridge/twitterimport.php @@ -583,15 +583,16 @@ class TwitterImport foreach ($toReplace as $part) { list($type, $object) = $part; + $orig = mb_substr($text, $object->indices[0], $object->indices[1] - $object->indices[0]); switch($type) { case self::URL: - $linkText = $this->makeUrlLink($object); + $linkText = $this->makeUrlLink($object, $orig); break; case self::HASHTAG: - $linkText = $this->makeHashtagLink($object); + $linkText = $this->makeHashtagLink($object, $orig); break; case self::MENTION: - $linkText = $this->makeMentionLink($object); + $linkText = $this->makeMentionLink($object, $orig); break; default: continue; @@ -601,32 +602,32 @@ class TwitterImport return $text; } - function makeUrlLink($object) + function makeUrlLink($object, $orig) { - return "{$object->url}"; + return "{$orig}"; } - function makeHashtagLink($object) + function makeHashtagLink($object, $orig) { - return "#" . self::tagLink($object->text); + return "#" . self::tagLink($object->text, substr($orig, 1)); } - function makeMentionLink($object) + function makeMentionLink($object, $orig) { - return "@".self::atLink($object->screen_name, $object->name); + return "@".self::atLink($object->screen_name, $object->name, substr($orig, 1)); } - static function tagLink($tag) + static function tagLink($tag, $orig) { - return "{$tag}"; + return "{$orig}"; } - static function atLink($screenName, $fullName=null) + static function atLink($screenName, $fullName, $orig) { if (!empty($fullName)) { - return "{$screenName}"; + return "{$orig}"; } else { - return "{$screenName}"; + return "{$orig}"; } } -- 2.39.5