Skip to content

Commit

Permalink
Don't encode strings to utf-8 before passing them to the dynamic libr…
Browse files Browse the repository at this point in the history
…ary.

It converts them from multibyte to unibyte which bypasses utf-8 validation.
  • Loading branch information
kurnevsky committed Dec 31, 2024
1 parent 0c4348f commit 4899052
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/emacs/fuzzy-matcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustPlatform.buildRustPackage {
cargoLock = {
lockFile = ./fuzzy-matcher/Cargo.lock;
outputHashes = {
"emacs-0.19.0" = "sha256-094GLODTvUpwjs77KTsAYBdytX726c2aNkyOS9sxRuU=";
"emacs-0.19.0" = "sha256-qMRNuGc+HgGwbwucxGC9KENHUh4yl8D8r+TINM6nTjY=";
};
};
}
6 changes: 3 additions & 3 deletions modules/emacs/fuzzy-matcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/emacs/fuzzy-matcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "fuzzy_matcher_el"
crate-type = ["cdylib"]

[dependencies]
emacs = { git = "https://github.com/kurnevsky/emacs-module-rs.git", rev = "297bdd761b3c827d9387708330f3cef62edd7be8" }
emacs = { git = "https://github.com/kurnevsky/emacs-module-rs.git", rev = "49665c9ae23b19711fc41e15ac526755f6a48072", features = [ "utf-8-validation" ] }
nucleo-matcher = "0.3"
lazy_static = "1.5"

Expand Down
4 changes: 1 addition & 3 deletions modules/emacs/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,7 @@ which LANG was detected but these are ignored."
(substring string 0 (- (length string) 1))
string))
(defun fuzzy-matcher-propertize (pattern candidate)
(let* ((score (fuzzy-matcher-fuzzy-indices
(encode-coding-string pattern 'utf-8 t)
(encode-coding-string (fuzzy-matcher-without-tofu-char candidate) 'utf-8 t)))
(let* ((score (fuzzy-matcher-fuzzy-indices pattern (fuzzy-matcher-without-tofu-char candidate)))
(candidate (copy-sequence candidate)))
(unless (string-empty-p pattern)
(put-text-property 0 1 'completion-score (- (* (or (car score) 0) 100) (length candidate)) candidate))
Expand Down

0 comments on commit 4899052

Please sign in to comment.