Compare commits

..

No commits in common. "master" and "v0.6.0" have entirely different histories.

4 changed files with 10 additions and 33 deletions

View file

@ -14,16 +14,6 @@ Procedure when bumping the version number:
## Unreleased ## Unreleased
## v0.6.1 - 2025-02-23
### Changed
- Updated set of emoji names
### Fixed
- Nick hue hashing algorithm in some edge cases
## v0.6.0 - 2025-02-21 ## v0.6.0 - 2025-02-21
### Added ### Added

View file

@ -1,6 +1,6 @@
[package] [package]
name = "euphoxide" name = "euphoxide"
version = "0.6.1" version = "0.6.0"
edition = "2021" edition = "2021"
[features] [features]

View file

@ -878,7 +878,7 @@
"fist_raised": "270a", "fist_raised": "270a",
"fist_right": "1f91c", "fist_right": "1f91c",
"five": "35-fe0f-20e3", "five": "35-fe0f-20e3",
"fjafjkldskf7jkfdj": "1f577-fe0f", "fjafjkldskf7jkfdj": "1f577",
"flags": "1f38f", "flags": "1f38f",
"flamingo": "1f9a9", "flamingo": "1f9a9",
"flashlight": "1f526", "flashlight": "1f526",
@ -958,7 +958,6 @@
"georgia": "1f1ec-1f1ea", "georgia": "1f1ec-1f1ea",
"ghana": "1f1ec-1f1ed", "ghana": "1f1ec-1f1ed",
"ghost": "1f47b", "ghost": "1f47b",
"ghoti": "1f41f",
"gibraltar": "1f1ec-1f1ee", "gibraltar": "1f1ec-1f1ee",
"gift": "1f381", "gift": "1f381",
"gift_heart": "1f49d", "gift_heart": "1f49d",
@ -2986,7 +2985,7 @@
"speaking_head": "1f5e3-fe0f", "speaking_head": "1f5e3-fe0f",
"speech_balloon": "1f4ac", "speech_balloon": "1f4ac",
"speedboat": "1f6a4", "speedboat": "1f6a4",
"spider": "1f577-fe0f", "spider": "1f577",
"spider_web": "1f578-fe0f", "spider_web": "1f578-fe0f",
"spiral_calendar": "1f5d3-fe0f", "spiral_calendar": "1f5d3-fe0f",
"spiral_notepad": "1f5d2-fe0f", "spiral_notepad": "1f5d2-fe0f",

View file

@ -5,10 +5,9 @@ use unicode_normalization::UnicodeNormalization;
use crate::emoji::Emoji; use crate::emoji::Emoji;
fn hue_normalize(emoji: &Emoji, text: &str) -> String { /// Does not remove emoji.
emoji fn hue_normalize(text: &str) -> String {
.remove(text) text.chars()
.chars()
.filter(|&c| c.is_ascii_alphanumeric() || c == '_' || c == '-') .filter(|&c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
.map(|c| c.to_ascii_lowercase()) .map(|c| c.to_ascii_lowercase())
.collect() .collect()
@ -16,7 +15,7 @@ fn hue_normalize(emoji: &Emoji, text: &str) -> String {
/// A re-implementation of [euphoria's nick hue hashing algorithm][0]. /// A re-implementation of [euphoria's nick hue hashing algorithm][0].
/// ///
/// [0]: https://github.com/CylonicRaider/heim/blob/097a1fde89ada53de2b70e51e635257f27956e4e/client/lib/heim/hueHash.js /// [0]: https://github.com/CylonicRaider/heim/blob/master/client/lib/hueHash.js
fn hue_hash(text: &str, offset: i64) -> u8 { fn hue_hash(text: &str, offset: i64) -> u8 {
let mut val = 0_i32; let mut val = 0_i32;
for bibyte in text.encode_utf16() { for bibyte in text.encode_utf16() {
@ -36,13 +35,7 @@ const GREENIE_OFFSET: i64 = 148 - 192; // 148 - hue_hash("greenie", 0)
/// This should be slightly faster than [`hue`] but produces incorrect results /// This should be slightly faster than [`hue`] but produces incorrect results
/// if any colon-delimited emoji are present. /// if any colon-delimited emoji are present.
pub fn hue_without_removing_emoji(nick: &str) -> u8 { pub fn hue_without_removing_emoji(nick: &str) -> u8 {
// An emoji-less version of hue_normalize let normalized = hue_normalize(nick);
let normalized = nick
.chars()
.filter(|&c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
.map(|c| c.to_ascii_lowercase())
.collect::<String>();
if normalized.is_empty() { if normalized.is_empty() {
hue_hash(nick, GREENIE_OFFSET) hue_hash(nick, GREENIE_OFFSET)
} else { } else {
@ -55,14 +48,9 @@ pub fn hue_without_removing_emoji(nick: &str) -> u8 {
/// This is a reimplementation of [euphoria's nick hue hashing algorithm][0]. It /// This is a reimplementation of [euphoria's nick hue hashing algorithm][0]. It
/// should always return the same value as the official client's implementation. /// should always return the same value as the official client's implementation.
/// ///
/// [0]: https://github.com/CylonicRaider/heim/blob/097a1fde89ada53de2b70e51e635257f27956e4e/client/lib/heim/hueHash.js /// [0]: https://github.com/CylonicRaider/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/hueHash.js
pub fn hue(emoji: &Emoji, nick: &str) -> u8 { pub fn hue(emoji: &Emoji, nick: &str) -> u8 {
let normalized = hue_normalize(emoji, nick); hue_without_removing_emoji(&emoji.remove(nick))
if normalized.is_empty() {
hue_hash(nick, GREENIE_OFFSET)
} else {
hue_hash(&normalized, GREENIE_OFFSET)
}
} }
/// Normalize a nick to a form that can be compared against other nicks. /// Normalize a nick to a form that can be compared against other nicks.