We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ampersands need to be escaped in WindowName widget
# Issue description
Ampersands in window names need to be changed in WindowName widget to "&amp;" before being passed to Pango/Cairo

# Qtile version
0.15.1

# Stack traces
Exception: parse_markup() failed for b'Seth Lakeman - King & Country'
2020-04-27 19:12:00,744 ERROR libqtile hook.py:fire():L373 Error in hook focus_change
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/libqtile/hook.py", line 371, in fire
    i(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/libqtile/widget/windowname.py", line 67, in update
    self.text = "%s%s" % (state, w.name if w and w.name else " ")
  File "/usr/lib/python3.8/site-packages/libqtile/widget/base.py", line 323, in text
    self.layout.text = self.formatted_text
  File "/usr/lib/python3.8/site-packages/libqtile/drawer.py", line 70, in text
    attrlist, value, accel_char = pangocffi.parse_markup(value)
  File "/usr/lib/python3.8/site-packages/libqtile/pangocffi.py", line 173, in parse_markup
    raise Exception("parse_markup() failed for %s" % value)
Exception: parse_markup() failed for b'Seth Lakeman - King & Country'

# Configuration
N/A

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libqtile/widget/windowname.py`
Content:
```
1 # Copyright (c) 2008, 2010 Aldo Cortesi
2 # Copyright (c) 2010 matt
3 # Copyright (c) 2011 Mounier Florian
4 # Copyright (c) 2012 Tim Neumann
5 # Copyright (c) 2013 Craig Barnes
6 # Copyright (c) 2014 Sean Vig
7 # Copyright (c) 2014 Tycho Andersen
8 #
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 # SOFTWARE.
26 
27 from libqtile import bar, hook
28 from libqtile.widget import base
29 
30 
31 class WindowName(base._TextBox):
32     """Displays the name of the window that currently has focus"""
33     orientations = base.ORIENTATION_HORIZONTAL
34     defaults = [
35         ('show_state', True, 'show window status before window name'),
36         ('for_current_screen', False, 'instead of this bars screen use currently active screen')
37     ]
38 
39     def __init__(self, width=bar.STRETCH, **config):
40         base._TextBox.__init__(self, width=width, **config)
41         self.add_defaults(WindowName.defaults)
42 
43     def _configure(self, qtile, bar):
44         base._TextBox._configure(self, qtile, bar)
45         hook.subscribe.client_name_updated(self.update)
46         hook.subscribe.focus_change(self.update)
47         hook.subscribe.float_change(self.update)
48 
49         @hook.subscribe.current_screen_change
50         def on_screen_changed():
51             if self.for_current_screen:
52                 self.update()
53 
54     def update(self, *args):
55         if self.for_current_screen:
56             w = self.qtile.current_screen.group.current_window
57         else:
58             w = self.bar.screen.group.current_window
59         state = ''
60         if self.show_state and w is not None:
61             if w.maximized:
62                 state = '[] '
63             elif w.minimized:
64                 state = '_ '
65             elif w.floating:
66                 state = 'V '
67         self.text = "%s%s" % (state, w.name if w and w.name else " ")
68         self.bar.draw()
69
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/libqtile/widget/windowname.py b/libqtile/widget/windowname.py
--- a/libqtile/widget/windowname.py
+++ b/libqtile/widget/windowname.py
@@ -24,7 +24,7 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from libqtile import bar, hook
+from libqtile import bar, hook, pangocffi
 from libqtile.widget import base
 
 
@@ -64,5 +64,6 @@
                 state = '_ '
             elif w.floating:
                 state = 'V '
-        self.text = "%s%s" % (state, w.name if w and w.name else " ")
+        unescaped = "%s%s" % (state, w.name if w and w.name else " ")
+        self.text = pangocffi.markup_escape_text(unescaped)
         self.bar.draw()

{"golden_diff": "diff --git a/libqtile/widget/windowname.py b/libqtile/widget/windowname.py\n--- a/libqtile/widget/windowname.py\n+++ b/libqtile/widget/windowname.py\n@@ -24,7 +24,7 @@\n # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n # SOFTWARE.\n \n-from libqtile import bar, hook\n+from libqtile import bar, hook, pangocffi\n from libqtile.widget import base\n \n \n@@ -64,5 +64,6 @@\n                 state = '_ '\n             elif w.floating:\n                 state = 'V '\n-        self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\n+        unescaped = \"%s%s\" % (state, w.name if w and w.name else \" \")\n+        self.text = pangocffi.markup_escape_text(unescaped)\n         self.bar.draw()\n", "issue": "Ampersands need to be escaped in WindowName widget\n# Issue description\r\nAmpersands in window names need to be changed in WindowName widget to \"&amp;\" before being passed to Pango/Cairo\r\n\r\n# Qtile version\r\n0.15.1\r\n\r\n# Stack traces\r\nException: parse_markup() failed for b'Seth Lakeman - King & Country'\r\n2020-04-27 19:12:00,744 ERROR libqtile hook.py:fire():L373 Error in hook focus_change\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/hook.py\", line 371, in fire\r\n    i(*args, **kwargs)\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/widget/windowname.py\", line 67, in update\r\n    self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/widget/base.py\", line 323, in text\r\n    self.layout.text = self.formatted_text\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/drawer.py\", line 70, in text\r\n    attrlist, value, accel_char = pangocffi.parse_markup(value)\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/pangocffi.py\", line 173, in parse_markup\r\n    raise Exception(\"parse_markup() failed for %s\" % value)\r\nException: parse_markup() failed for b'Seth Lakeman - King & Country'\r\n\r\n# Configuration\r\nN/A\n", "before_files": [{"content": "# Copyright (c) 2008, 2010 Aldo Cortesi\n# Copyright (c) 2010 matt\n# Copyright (c) 2011 Mounier Florian\n# Copyright (c) 2012 Tim Neumann\n# Copyright (c) 2013 Craig Barnes\n# Copyright (c) 2014 Sean Vig\n# Copyright (c) 2014 Tycho Andersen\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom libqtile import bar, hook\nfrom libqtile.widget import base\n\n\nclass WindowName(base._TextBox):\n    \"\"\"Displays the name of the window that currently has focus\"\"\"\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults = [\n        ('show_state', True, 'show window status before window name'),\n        ('for_current_screen', False, 'instead of this bars screen use currently active screen')\n    ]\n\n    def __init__(self, width=bar.STRETCH, **config):\n        base._TextBox.__init__(self, width=width, **config)\n        self.add_defaults(WindowName.defaults)\n\n    def _configure(self, qtile, bar):\n        base._TextBox._configure(self, qtile, bar)\n        hook.subscribe.client_name_updated(self.update)\n        hook.subscribe.focus_change(self.update)\n        hook.subscribe.float_change(self.update)\n\n        @hook.subscribe.current_screen_change\n        def on_screen_changed():\n            if self.for_current_screen:\n                self.update()\n\n    def update(self, *args):\n        if self.for_current_screen:\n            w = self.qtile.current_screen.group.current_window\n        else:\n            w = self.bar.screen.group.current_window\n        state = ''\n        if self.show_state and w is not None:\n            if w.maximized:\n                state = '[] '\n            elif w.minimized:\n                state = '_ '\n            elif w.floating:\n                state = 'V '\n        self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\n        self.bar.draw()\n", "path": "libqtile/widget/windowname.py"}], "after_files": [{"content": "# Copyright (c) 2008, 2010 Aldo Cortesi\n# Copyright (c) 2010 matt\n# Copyright (c) 2011 Mounier Florian\n# Copyright (c) 2012 Tim Neumann\n# Copyright (c) 2013 Craig Barnes\n# Copyright (c) 2014 Sean Vig\n# Copyright (c) 2014 Tycho Andersen\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom libqtile import bar, hook, pangocffi\nfrom libqtile.widget import base\n\n\nclass WindowName(base._TextBox):\n    \"\"\"Displays the name of the window that currently has focus\"\"\"\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults = [\n        ('show_state', True, 'show window status before window name'),\n        ('for_current_screen', False, 'instead of this bars screen use currently active screen')\n    ]\n\n    def __init__(self, width=bar.STRETCH, **config):\n        base._TextBox.__init__(self, width=width, **config)\n        self.add_defaults(WindowName.defaults)\n\n    def _configure(self, qtile, bar):\n        base._TextBox._configure(self, qtile, bar)\n        hook.subscribe.client_name_updated(self.update)\n        hook.subscribe.focus_change(self.update)\n        hook.subscribe.float_change(self.update)\n\n        @hook.subscribe.current_screen_change\n        def on_screen_changed():\n            if self.for_current_screen:\n                self.update()\n\n    def update(self, *args):\n        if self.for_current_screen:\n            w = self.qtile.current_screen.group.current_window\n        else:\n            w = self.bar.screen.group.current_window\n        state = ''\n        if self.show_state and w is not None:\n            if w.maximized:\n                state = '[] '\n            elif w.minimized:\n                state = '_ '\n            elif w.floating:\n                state = 'V '\n        unescaped = \"%s%s\" % (state, w.name if w and w.name else \" \")\n        self.text = pangocffi.markup_escape_text(unescaped)\n        self.bar.draw()\n", "path": "libqtile/widget/windowname.py"}]}