Converts a UTF-8 string into markup 74/199474/6
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 12 Feb 2019 02:05:12 +0000 (11:05 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Fri, 26 Apr 2019 06:00:16 +0000 (15:00 +0900)
- Converts a UTF-8 string into markup(HTML-like) to handle special
characters such as &, <, /,  and >/. (There was an issue that the
string composed with an app label contains '&' character couldn't
be displayed properly.)

Change-Id: Ie72f4919472ead9513cdc6d904e3e7fee860040f
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
src/notification-daemon/ui/Po.cpp

index 2b40973..a10ea5c 100644 (file)
@@ -64,8 +64,14 @@ std::string makeFromFormat(const char *format, Args... args) {
     if (ret == -1) {
         throw ErrnoException("asprintf failed");
     }
-    std::unique_ptr<char, decltype(std::free) *> bufPtr(buf, std::free);
-    return std::string(buf);
+    char *markup = elm_entry_utf8_to_markup(buf);
+    free(buf);
+    if (!markup) {
+        ALOGE("markup is NULL");
+        throw ErrnoException("elm_entry_utf8_to_markup failed");
+    }
+    std::unique_ptr<char, decltype(std::free) *> bufPtr(markup, std::free);
+    return std::string(markup);
 }
 
 const char *getFormat(enum MsgType type) {