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:
shbhmexe
2025-12-27 16:02:22 +05:30
committed by Kelson
parent fb6448011b
commit 503e55c87e
7 changed files with 19 additions and 17 deletions

View File

@@ -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;