- further escaping added for multibyte expressions in %def, %call attributes
[ticket:24]
diff --git a/CHANGES b/CHANGES
index 72967ca..62b7d7d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,8 @@
 True otherwise.  this way you can say % if caller:\n ${caller.body()}\n% endif
 - <%include> has an "args" attribute that can pass arguments to the called
 template (keyword arguments only, must be declared in that page's <%page> tag.)
+- further escaping added for multibyte expressions in %def, %call attributes
+[ticket:24]
 
 0.1.3
 - ***Small Syntax Change*** - the single line comment character is now
diff --git a/lib/mako/lexer.py b/lib/mako/lexer.py
index 9cfb140..09c52d4 100644
--- a/lib/mako/lexer.py
+++ b/lib/mako/lexer.py
@@ -191,7 +191,7 @@
             if attr:
                 for att in re.findall(r"\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")", attr):
                     (key, val1, val2) = att
-                    attributes[key] = val1 or val2
+                    attributes[key] = self.escape_code(val1 or val2)
             self.append_node(parsetree.Tag, keyword, attributes)
             if isend:
                 self.tag.pop()
diff --git a/test/template.py b/test/template.py
index 658651d..196fefc 100644
--- a/test/template.py
+++ b/test/template.py
@@ -79,6 +79,23 @@
         """.encode('utf-8'))
         assert template.render_unicode().strip() == u"""hi, drôle de petit voix m’a réveillé."""
     
+    def test_unicode_literal_in_def(self):
+        template = Template(u"""## -*- coding: utf-8 -*-
+        <%def name="bello(foo, bar)">
+        Foo: ${ foo }
+        Bar: ${ bar }
+        </%def>
+        <%call expr="bello(foo=u'árvíztűrő tükörfúrógép', bar=u'ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP')">
+        </%call>""".encode('utf-8'))
+        assert flatten_result(template.render_unicode()) == u"""Foo: árvíztűrő tükörfúrógép Bar: ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP"""
+        
+        template = Template(u"""## -*- coding: utf-8 -*-
+        <%def name="hello(foo=u'árvíztűrő tükörfúrógép', bar=u'ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP')">
+        Foo: ${ foo }
+        Bar: ${ bar }
+        </%def>
+        ${ hello() }""".encode('utf-8'))
+        assert flatten_result(template.render_unicode()) == u"""Foo: árvíztűrő tükörfúrógép Bar: ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP"""
         
     def test_input_encoding(self):
         """test the 'input_encoding' flag on Template, and that unicode objects arent double-decoded"""