mirror of
https://github.com/kiwix/libkiwix.git
synced 2026-02-24 18:28:17 -05:00
Fix various stability and correctness issues in libkiwix
- Fix infinite loop and memory leak in Windows network tools (networkTools.cpp) - Improve exception safety in removeAccents using RAII (stringTools.cpp) - Change getBookById to return by value to avoid dangling references (library.cpp) - Use proper constant for HTTP 416 instead of magic number (response.cpp) - Fix exception slicing in getDownload re-throw (downloader.cpp) Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
This commit is contained in:
@@ -74,11 +74,10 @@ std::string kiwix::removeAccents(const std::string& text)
|
||||
loadICUExternalTables();
|
||||
ucnv_setDefaultName("UTF-8");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
auto removeAccentsTrans = icu::Transliterator::createInstance(
|
||||
"Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status);
|
||||
std::unique_ptr<icu::Transliterator> removeAccentsTrans(icu::Transliterator::createInstance(
|
||||
"Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status));
|
||||
icu::UnicodeString ustring(text.c_str());
|
||||
removeAccentsTrans->transliterate(ustring);
|
||||
delete removeAccentsTrans;
|
||||
std::string unaccentedText;
|
||||
ustring.toUTF8String(unaccentedText);
|
||||
return unaccentedText;
|
||||
|
||||
Reference in New Issue
Block a user