Patchwork [bitbake-devel,3/3] Hob: Interpret some special characters for label markup

login
register
mail settings
Submitter Shane Wang
Date June 2, 2012, 4:54 a.m.
Message ID <a83d5af816b9390f71165f5a2ccd51fe69799d04.1338612620.git.shane.wang@intel.com>
Download mbox | patch
Permalink /patch/29127/
State New
Headers show

Comments

Shane Wang - June 2, 2012, 4:54 a.m.
Interpret some special characters for label markup, such as &, <, >, etc.
Otherwise, the message dialog can't show them, and worsely, it makes the
whole message blank.

[Yocto #2492]

Signed-off-by: Shane Wang <shane.wang@intel.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index eaf18ab..ed6c6cf 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -374,6 +374,15 @@  class Builder(gtk.Window):
         END_NOOP              : None,
     }
 
+    @classmethod
+    def interpret_markup(cls, msg):
+        msg = msg.replace('&', '&amp;')
+        msg = msg.replace('<', '&lt;')
+        msg = msg.replace('>', '&gt;')
+        msg = msg.replace('"', '&quot;')
+        msg = msg.replace("'", "&acute;")
+        return msg
+
     def __init__(self, hobHandler, recipe_model, package_model):
         super(Builder, self).__init__()
 
@@ -729,7 +738,7 @@  class Builder(gtk.Window):
 
     def show_error_dialog(self, msg):
         lbl = "<b>Error</b>\n"
-        lbl = lbl + "%s\n\n" % msg
+        lbl = lbl + "%s\n\n" % Builder.interpret_markup(msg)
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
         button = dialog.add_button("Close", gtk.RESPONSE_OK)
         HobButton.style_button(button)
@@ -909,7 +918,7 @@  class Builder(gtk.Window):
         self.build_failed()
 
     def handler_no_provider_cb(self, running_build, msg):
-        dialog = CrumbsMessageDialog(self, msg, gtk.STOCK_DIALOG_INFO)
+        dialog = CrumbsMessageDialog(self, Builder.interpret_markup(msg), gtk.STOCK_DIALOG_INFO)
         button = dialog.add_button("Close", gtk.RESPONSE_OK)
         HobButton.style_button(button)
         dialog.run()