From: Bowon Ryu Date: Wed, 28 May 2025 06:24:21 +0000 (+0900) Subject: Fix accessibility anchor issue X-Git-Tag: dali_2.4.21~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F324877%2F2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Fix accessibility anchor issue - UTF-8 encoding is required. - Previously, assigning UTF-32 characters to std::string worked by coincidence. - In corner cases, the href of an anchor can be nullptr. - Assigning nullptr to std::string can cause a crash. Change-Id: I247b118408daaeb4f0560e167daa33e06e01614b Signed-off-by: Bowon Ryu --- diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index 756fda462f..20aeb95bb0 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -1753,9 +1753,18 @@ Toolkit::TextAnchor Controller::Impl::CreateAnchorActor(Anchor anchor) actor.SetProperty(Actor::Property::POSITION, anchorPosition); const Vector2 anchorSize = GetAnchorSize(anchor); actor.SetProperty(Actor::Property::SIZE, anchorSize); - std::string anchorText(mModel->mLogicalModel->mText.Begin() + anchor.startIndex, mModel->mLogicalModel->mText.Begin() + anchor.endIndex); + + std::string anchorText; + std::string anchorHref = anchor.href ? anchor.href : ""; + Length numberOfAnchorCharacters = anchor.endIndex - anchor.startIndex; + if(numberOfAnchorCharacters > 0u && mModel->mLogicalModel->mText.Size() >= numberOfAnchorCharacters) + { + Utf32ToUtf8(mModel->mLogicalModel->mText.Begin() + anchor.startIndex, numberOfAnchorCharacters, anchorText); + } + DALI_LOG_INFO(gLogFilter, Debug::General, "CreateAnchorActor NAME:%s, URI:%s\n", anchorText.c_str(), anchorHref.c_str()); + actor.SetProperty(Actor::Property::NAME, anchorText); - actor.SetProperty(Toolkit::TextAnchor::Property::URI, std::string(anchor.href)); + actor.SetProperty(Toolkit::TextAnchor::Property::URI, anchorHref); actor.SetProperty(Toolkit::TextAnchor::Property::START_CHARACTER_INDEX, static_cast(anchor.startIndex)); actor.SetProperty(Toolkit::TextAnchor::Property::END_CHARACTER_INDEX, static_cast(anchor.endIndex)); return actor;