prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Drafts are leaked in feeds
  Reported by @kayhayen in the mailing list. Proposed patch breaks tests, so checking things out a bit more carefully.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nikola/plugins/task/rss.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright © 2012-2014 Roberto Alsina and others.
  4 
  5 # Permission is hereby granted, free of charge, to any
  6 # person obtaining a copy of this software and associated
  7 # documentation files (the "Software"), to deal in the
  8 # Software without restriction, including without limitation
  9 # the rights to use, copy, modify, merge, publish,
  10 # distribute, sublicense, and/or sell copies of the
  11 # Software, and to permit persons to whom the Software is
  12 # furnished to do so, subject to the following conditions:
  13 #
  14 # The above copyright notice and this permission notice
  15 # shall be included in all copies or substantial portions of
  16 # the Software.
  17 #
  18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  21 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  22 # OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26 
  27 from __future__ import unicode_literals, print_function
  28 import os
  29 try:
  30     from urlparse import urljoin
  31 except ImportError:
  32     from urllib.parse import urljoin  # NOQA
  33 
  34 from nikola import utils
  35 from nikola.plugin_categories import Task
  36 
  37 
  38 class GenerateRSS(Task):
  39     """Generate RSS feeds."""
  40 
  41     name = "generate_rss"
  42 
  43     def set_site(self, site):
  44         site.register_path_handler('rss', self.rss_path)
  45         return super(GenerateRSS, self).set_site(site)
  46 
  47     def gen_tasks(self):
  48         """Generate RSS feeds."""
  49         kw = {
  50             "translations": self.site.config["TRANSLATIONS"],
  51             "filters": self.site.config["FILTERS"],
  52             "blog_title": self.site.config["BLOG_TITLE"],
  53             "site_url": self.site.config["SITE_URL"],
  54             "blog_description": self.site.config["BLOG_DESCRIPTION"],
  55             "output_folder": self.site.config["OUTPUT_FOLDER"],
  56             "rss_teasers": self.site.config["RSS_TEASERS"],
  57             "hide_untranslated_posts": self.site.config['HIDE_UNTRANSLATED_POSTS'],
  58             "feed_length": self.site.config['FEED_LENGTH'],
  59         }
  60         self.site.scan_posts()
  61         yield self.group_task()
  62         for lang in kw["translations"]:
  63             output_name = os.path.join(kw['output_folder'],
  64                                        self.site.path("rss", None, lang))
  65             deps = []
  66             if kw["hide_untranslated_posts"]:
  67                 posts = [x for x in self.site.timeline if x.use_in_feeds
  68                          and x.is_translation_available(lang)][:10]
  69             else:
  70                 posts = [x for x in self.site.timeline if x.use_in_feeds][:10]
  71             for post in posts:
  72                 deps += post.deps(lang)
  73 
  74             feed_url = urljoin(self.site.config['BASE_URL'], self.site.link("rss", None, lang).lstrip('/'))
  75             yield {
  76                 'basename': 'generate_rss',
  77                 'name': os.path.normpath(output_name),
  78                 'file_dep': deps,
  79                 'targets': [output_name],
  80                 'actions': [(utils.generic_rss_renderer,
  81                             (lang, kw["blog_title"], kw["site_url"],
  82                              kw["blog_description"], posts, output_name,
  83                              kw["rss_teasers"], kw['feed_length'], feed_url))],
  84                 'task_dep': ['render_posts'],
  85                 'clean': True,
  86                 'uptodate': [utils.config_changed(kw)],
  87             }
  88 
  89     def rss_path(self, name, lang):
  90         return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
  91                               self.site.config['RSS_PATH'], 'rss.xml'] if _f]
  92
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/nikola/plugins/task/rss.py b/nikola/plugins/task/rss.py
  --- a/nikola/plugins/task/rss.py
  +++ b/nikola/plugins/task/rss.py
  @@ -58,6 +58,11 @@
               "feed_length": self.site.config['FEED_LENGTH'],
           }
           self.site.scan_posts()
  +        # Check for any changes in the state of use_in_feeds for any post.
  +        # Issue #934
  +        kw['use_in_feeds_status'] = ''.join(
  +            ['T' if x.use_in_feeds else 'F' for x in self.site.timeline]
  +        )
           yield self.group_task()
           for lang in kw["translations"]:
               output_name = os.path.join(kw['output_folder'],
  
verification_info: {"golden_diff": "diff --git a/nikola/plugins/task/rss.py b/nikola/plugins/task/rss.py\n--- a/nikola/plugins/task/rss.py\n+++ b/nikola/plugins/task/rss.py\n@@ -58,6 +58,11 @@\n             \"feed_length\": self.site.config['FEED_LENGTH'],\n         }\n         self.site.scan_posts()\n+        # Check for any changes in the state of use_in_feeds for any post.\n+        # Issue #934\n+        kw['use_in_feeds_status'] = ''.join(\n+            ['T' if x.use_in_feeds else 'F' for x in self.site.timeline]\n+        )\n         yield self.group_task()\n         for lang in kw[\"translations\"]:\n             output_name = os.path.join(kw['output_folder'],\n", "issue": "Drafts are leaked in feeds\nReported by @kayhayen in the mailing list. Proposed patch breaks tests, so checking things out a bit more carefully.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2014 Roberto Alsina and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# 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\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import unicode_literals, print_function\nimport os\ntry:\n    from urlparse import urljoin\nexcept ImportError:\n    from urllib.parse import urljoin  # NOQA\n\nfrom nikola import utils\nfrom nikola.plugin_categories import Task\n\n\nclass GenerateRSS(Task):\n    \"\"\"Generate RSS feeds.\"\"\"\n\n    name = \"generate_rss\"\n\n    def set_site(self, site):\n        site.register_path_handler('rss', self.rss_path)\n        return super(GenerateRSS, self).set_site(site)\n\n    def gen_tasks(self):\n        \"\"\"Generate RSS feeds.\"\"\"\n        kw = {\n            \"translations\": self.site.config[\"TRANSLATIONS\"],\n            \"filters\": self.site.config[\"FILTERS\"],\n            \"blog_title\": self.site.config[\"BLOG_TITLE\"],\n            \"site_url\": self.site.config[\"SITE_URL\"],\n            \"blog_description\": self.site.config[\"BLOG_DESCRIPTION\"],\n            \"output_folder\": self.site.config[\"OUTPUT_FOLDER\"],\n            \"rss_teasers\": self.site.config[\"RSS_TEASERS\"],\n            \"hide_untranslated_posts\": self.site.config['HIDE_UNTRANSLATED_POSTS'],\n            \"feed_length\": self.site.config['FEED_LENGTH'],\n        }\n        self.site.scan_posts()\n        yield self.group_task()\n        for lang in kw[\"translations\"]:\n            output_name = os.path.join(kw['output_folder'],\n                                       self.site.path(\"rss\", None, lang))\n            deps = []\n            if kw[\"hide_untranslated_posts\"]:\n                posts = [x for x in self.site.timeline if x.use_in_feeds\n                         and x.is_translation_available(lang)][:10]\n            else:\n                posts = [x for x in self.site.timeline if x.use_in_feeds][:10]\n            for post in posts:\n                deps += post.deps(lang)\n\n            feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(\"rss\", None, lang).lstrip('/'))\n            yield {\n                'basename': 'generate_rss',\n                'name': os.path.normpath(output_name),\n                'file_dep': deps,\n                'targets': [output_name],\n                'actions': [(utils.generic_rss_renderer,\n                            (lang, kw[\"blog_title\"], kw[\"site_url\"],\n                             kw[\"blog_description\"], posts, output_name,\n                             kw[\"rss_teasers\"], kw['feed_length'], feed_url))],\n                'task_dep': ['render_posts'],\n                'clean': True,\n                'uptodate': [utils.config_changed(kw)],\n            }\n\n    def rss_path(self, name, lang):\n        return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                              self.site.config['RSS_PATH'], 'rss.xml'] if _f]\n", "path": "nikola/plugins/task/rss.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2014 Roberto Alsina and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# 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\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import unicode_literals, print_function\nimport os\ntry:\n    from urlparse import urljoin\nexcept ImportError:\n    from urllib.parse import urljoin  # NOQA\n\nfrom nikola import utils\nfrom nikola.plugin_categories import Task\n\n\nclass GenerateRSS(Task):\n    \"\"\"Generate RSS feeds.\"\"\"\n\n    name = \"generate_rss\"\n\n    def set_site(self, site):\n        site.register_path_handler('rss', self.rss_path)\n        return super(GenerateRSS, self).set_site(site)\n\n    def gen_tasks(self):\n        \"\"\"Generate RSS feeds.\"\"\"\n        kw = {\n            \"translations\": self.site.config[\"TRANSLATIONS\"],\n            \"filters\": self.site.config[\"FILTERS\"],\n            \"blog_title\": self.site.config[\"BLOG_TITLE\"],\n            \"site_url\": self.site.config[\"SITE_URL\"],\n            \"blog_description\": self.site.config[\"BLOG_DESCRIPTION\"],\n            \"output_folder\": self.site.config[\"OUTPUT_FOLDER\"],\n            \"rss_teasers\": self.site.config[\"RSS_TEASERS\"],\n            \"hide_untranslated_posts\": self.site.config['HIDE_UNTRANSLATED_POSTS'],\n            \"feed_length\": self.site.config['FEED_LENGTH'],\n        }\n        self.site.scan_posts()\n        # Check for any changes in the state of use_in_feeds for any post.\n        # Issue #934\n        kw['use_in_feeds_status'] = ''.join(\n            ['T' if x.use_in_feeds else 'F' for x in self.site.timeline]\n        )\n        yield self.group_task()\n        for lang in kw[\"translations\"]:\n            output_name = os.path.join(kw['output_folder'],\n                                       self.site.path(\"rss\", None, lang))\n            deps = []\n            if kw[\"hide_untranslated_posts\"]:\n                posts = [x for x in self.site.timeline if x.use_in_feeds\n                         and x.is_translation_available(lang)][:10]\n            else:\n                posts = [x for x in self.site.timeline if x.use_in_feeds][:10]\n            for post in posts:\n                deps += post.deps(lang)\n\n            feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(\"rss\", None, lang).lstrip('/'))\n            yield {\n                'basename': 'generate_rss',\n                'name': os.path.normpath(output_name),\n                'file_dep': deps,\n                'targets': [output_name],\n                'actions': [(utils.generic_rss_renderer,\n                            (lang, kw[\"blog_title\"], kw[\"site_url\"],\n                             kw[\"blog_description\"], posts, output_name,\n                             kw[\"rss_teasers\"], kw['feed_length'], feed_url))],\n                'task_dep': ['render_posts'],\n                'clean': True,\n                'uptodate': [utils.config_changed(kw)],\n            }\n\n    def rss_path(self, name, lang):\n        return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                              self.site.config['RSS_PATH'], 'rss.xml'] if _f]\n", "path": "nikola/plugins/task/rss.py"}]}