internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: plone/Products.CMFPlone

Issue:
bundle with more than one resource break compiling TTW and in filesystem
I get the following error if i try to add more than one resource to a bundle.
I tested with beta4 and coredev buildout.
It fails on compiling the less files.

```
2015-09-01 14:10:19 ERROR Zope.SiteErrorLog 1441109419.190.013584610872 http://localhost:8080/p1/@@resourceregistry-controlpanel
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFPlone.controlpanel.browser.resourceregistry, line 172, in __call__
  Module Products.CMFPlone.controlpanel.browser.resourceregistry, line 332, in save_less_build
TypeError: sequence item 0: expected string, list found
```



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/resourceregistry.py b/Products/CMFPlone/controlpanel/browser/resourceregistry.py
--- a/Products/CMFPlone/controlpanel/browser/resourceregistry.py
+++ b/Products/CMFPlone/controlpanel/browser/resourceregistry.py
@@ -331,8 +331,13 @@ def save_less_build(self):
         overrides = OverrideFolderManager(self.context)
         req = self.request
         filepath = 'static/%s-compiled.css' % req.form['bundle']
-        data = '\n'.join([req.form[k] for k in req.form.keys()
-                          if k.startswith('data-')])
+        data = ''
+        for key, value in req.form.items():
+            if not key.startswith('data-'):
+                continue
+            if isinstance(value, basestring):
+                value = [value]
+            data += '\n'.join(value) + '\n'
         overrides.save_file(filepath, data)
         bundle = self.get_bundles().get(req.form['bundle'])
         if bundle:


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Group administration: AttributeError: 'NoneType' object has no attribute 'getGroupTitleOrName'
/Plone2/@@usergroup-groupmembership?groupname=None

gives me

Here is the full error message:

Display traceback as text

Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.CMFPlone.controlpanel.browser.usergroups_groupmembership, line 69, in **call**
Module Products.CMFPlone.controlpanel.browser.usergroups_groupmembership, line 16, in update
AttributeError: 'NoneType' object has no attribute 'getGroupTitleOrName'

This happens when you click on "new group" and then on the "group members" tab.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py b/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
--- a/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
+++ b/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
@@ -13,6 +13,9 @@ def update(self):
         self.gtool = getToolByName(self, 'portal_groups')
         self.mtool = getToolByName(self, 'portal_membership')
         self.group = self.gtool.getGroupById(self.groupname)
+        if self.group is None:
+            return
+
         self.grouptitle = self.group.getGroupTitleOrName() or self.groupname
 
         self.request.set('grouproles', self.group.getRoles() if self.group else [])


Test patch:
Repository: plone/Products.CMFPlone

Issue:
mail controlpanel: doesn't keep password field
Saving the mail settings in the controlpanel doesn't keep the password field value, as it is obviously never shown in ESMTP password.

Steps to reproduce:
1. Fill in ESMTP username and ESMTP password. Save settings. They are correctly stored.
2. Apply save settings again. ESMTP password is incorrectly stored as None.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/mail.py b/Products/CMFPlone/controlpanel/browser/mail.py
--- a/Products/CMFPlone/controlpanel/browser/mail.py
+++ b/Products/CMFPlone/controlpanel/browser/mail.py
@@ -36,6 +36,10 @@ def save(self):
         if errors:
             self.status = self.formErrorsMessage
             return False
+        #keep password field
+        if (data.get('smtp_userid') is not None
+            and data.get('smtp_pass') is None):
+            del data['smtp_pass']
         self.applyChanges(data)
         return True
 


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Author feedback form broken
Author feedback seems to have been missed in the refactoring of settings into the registry. It stills expects to find portal.email_from_name



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/browser/author.py b/Products/CMFPlone/browser/author.py
--- a/Products/CMFPlone/browser/author.py
+++ b/Products/CMFPlone/browser/author.py
@@ -104,7 +104,8 @@ def handle_send(self, action):
             message = self.feedback_template(
                 self, send_from_address=send_from_address,
                 sender_id=sender_id, url=referer, subject=subject,
-                message=message, encoding=email_charset
+                message=message, encoding=email_charset,
+                email_from_name=mail_settings.email_from_name
             )
 
             message = message.encode(email_charset)


Test patch:
Repository: plone/Products.CMFPlone

Issue:
CSS bundles generation breaks background images relative urls
This is a bug related to PR #1300.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py
--- a/Products/CMFPlone/resources/browser/combine.py
+++ b/Products/CMFPlone/resources/browser/combine.py
@@ -1,3 +1,4 @@
+import re
 from zExceptions import NotFound
 from Acquisition import aq_base
 from datetime import datetime
@@ -79,7 +80,15 @@ def write_css(context, folder, meta_bundle):
         IBundleRegistry, prefix="plone.bundles", check=False)
     for bundle in bundles.values():
         if bundle.merge_with == meta_bundle:
-            resources.append(get_resource(context, bundle.csscompilation))
+            css = get_resource(context, bundle.csscompilation)
+            # Preserve relative urls:
+            # we prefix with '../'' any url not starting with '/'
+            # or http: or data:
+            css = re.sub(
+                r"""(url\(['"]?(?!['"]?([a-z]+:|\/)))""",
+                r'\1../',
+                css)
+            resources.append(css)
 
     fi = StringIO()
     for script in resources:


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Resources from third party add-ons are not being included in compiled plone-legacy bundle
Seems JS resources registered in Plone 5 using old approach (`jsregistry.xml`) are not included in the final compilation: I installed an add-on and, even as I can see the JS resources listed in `default.js`, the source code is not present.

If I enable development mode, then I can see the source code included in `plone-legacy-compiled.js` and it's executed normally.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py
--- a/Products/CMFPlone/resources/browser/combine.py
+++ b/Products/CMFPlone/resources/browser/combine.py
@@ -31,6 +31,14 @@ def get_production_resource_directory():
 
 
 def get_resource(context, path):
+    if path.startswith('++plone++'):
+        # ++plone++ resources can be customized, we return their override
+        # value if any
+        overrides = get_override_directory(context)
+        filepath = path[9:]
+        if overrides.isFile(filepath):
+            return overrides.readFile(filepath)
+
     resource = context.unrestrictedTraverse(path)
     if isinstance(resource, FilesystemFile):
         (directory, sep, filename) = path.rpartition('/')
@@ -96,13 +104,17 @@ def write_css(context, folder, meta_bundle):
     folder.writeFile(meta_bundle + ".css", fi)
 
 
-def combine_bundles(context):
+def get_override_directory(context):
     persistent_directory = queryUtility(IResourceDirectory, name="persistent")
     if persistent_directory is None:
         return
     if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:
         persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)
-    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+    return persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+
+
+def combine_bundles(context):
+    container = get_override_directory(context)
     if PRODUCTION_RESOURCE_DIRECTORY not in container:
         container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)
     production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]


Test patch:
diff --git a/Products/CMFPlone/tests/test_metabundles.py b/Products/CMFPlone/tests/test_metabundles.py
--- a/Products/CMFPlone/tests/test_metabundles.py
+++ b/Products/CMFPlone/tests/test_metabundles.py
@@ -38,3 +38,16 @@ def test_default_js_bundle(self):
             "jQuery",
             self.production_folder.readFile('default.js')
         )
+
+    def test_overrides(self):
+        persistent_directory = getUtility(
+            IResourceDirectory, name="persistent")
+        container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+        container.makeDirectory('static')
+        static = container['static']
+        static.writeFile('plone-legacy-compiled.js', 'alert("Overrided legacy!");')
+        combine_bundles(self.portal)
+        self.assertIn(
+            'alert("Overrided legacy!");',
+            self.production_folder.readFile('default.js')
+        )
Repository: plone/Products.CMFPlone

Issue:
Resources from third party add-ons are not being included in compiled plone-legacy bundle
Seems JS resources registered in Plone 5 using old approach (`jsregistry.xml`) are not included in the final compilation: I installed an add-on and, even as I can see the JS resources listed in `default.js`, the source code is not present.

If I enable development mode, then I can see the source code included in `plone-legacy-compiled.js` and it's executed normally.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py
--- a/Products/CMFPlone/resources/browser/combine.py
+++ b/Products/CMFPlone/resources/browser/combine.py
@@ -30,6 +30,14 @@ def get_production_resource_directory():
 
 
 def get_resource(context, path):
+    if path.startswith('++plone++'):
+        # ++plone++ resources can be customized, we return their override
+        # value if any
+        overrides = get_override_directory(context)
+        filepath = path[9:]
+        if overrides.isFile(filepath):
+            return overrides.readFile(filepath)
+
     resource = context.unrestrictedTraverse(path)
     if isinstance(resource, FilesystemFile):
         (directory, sep, filename) = path.rpartition('/')
@@ -87,13 +95,17 @@ def write_css(context, folder, meta_bundle):
     folder.writeFile(meta_bundle + ".css", fi)
 
 
-def combine_bundles(context):
+def get_override_directory(context):
     persistent_directory = queryUtility(IResourceDirectory, name="persistent")
     if persistent_directory is None:
         return
     if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:
         persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)
-    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+    return persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+
+
+def combine_bundles(context):
+    container = get_override_directory(context)
     if PRODUCTION_RESOURCE_DIRECTORY not in container:
         container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)
     production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]


Test patch:
diff --git a/Products/CMFPlone/tests/test_metabundles.py b/Products/CMFPlone/tests/test_metabundles.py
--- a/Products/CMFPlone/tests/test_metabundles.py
+++ b/Products/CMFPlone/tests/test_metabundles.py
@@ -38,3 +38,16 @@ def test_default_js_bundle(self):
             "jQuery",
             self.production_folder.readFile('default.js')
         )
+
+    def test_overrides(self):
+        persistent_directory = getUtility(
+            IResourceDirectory, name="persistent")
+        container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+        container.makeDirectory('static')
+        static = container['static']
+        static.writeFile('plone-legacy-compiled.js', 'alert("Overrided legacy!");')
+        combine_bundles(self.portal)
+        self.assertIn(
+            'alert("Overrided legacy!");',
+            self.production_folder.readFile('default.js')
+        )
Repository: plone/Products.CMFPlone

Issue:
CSS bundles generation breaks background images relative urls
This is a bug related to PR #1300.



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py
--- a/Products/CMFPlone/resources/browser/combine.py
+++ b/Products/CMFPlone/resources/browser/combine.py
@@ -89,12 +89,13 @@ def write_css(context, folder, meta_bundle):
     for bundle in bundles.values():
         if bundle.merge_with == meta_bundle and bundle.csscompilation:
             css = get_resource(context, bundle.csscompilation)
-            # Preserve relative urls:
-            # we prefix with '../'' any url not starting with '/'
-            # or http: or data:
+            (path, sep, filename) = bundle.csscompilation.rpartition('/')
+            # Process relative urls:
+            # we prefix with current resource path any url not starting with
+            # '/' or http: or data:
             css = re.sub(
                 r"""(url\(['"]?(?!['"]?([a-z]+:|\/)))""",
-                r'\1../',
+                r'\1%s/' % path,
                 css)
             resources.append(css)
 


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Plone 5 - the addons control panel no longer shows the addon version number



Discussion:
here is a screenshot:

![selection_013](https://cloud.githubusercontent.com/assets/341393/13792758/43c9be44-ead2-11e5-9204-bd6ee09c24a2.png)

This is still an issue.
I don't know how this information was obtained before, but I think this was lost at some point when we decide to get rid of the `portal_quickinstaller` tool.

as long as I see, profiles don't include version information:

```python
(Pdb) pp [p for p in profiles if p['title'] == 'collective.lazysizes']
[{'description': u' Integration of lazysizes, a lightweight lazy loader, into Plone.',
  'for': None,
  'id': u'collective.lazysizes:default',
  'path': u'/home/hvelarde/collective/lazysizes/src/collective/lazysizes/profiles/default',
  'post_handler': None,
  'pre_handler': None,
  'product': 'collective.lazysizes',
  'title': u'collective.lazysizes',
  'type': 2,
  'version': u'7'}]
```

probably we need to hack `portal_setup.listProfileInfo()` to include the information; any ideas @mauritsvanrees?

alternatively we can add a function to get the version number:

```python
(Pdb) import pkg_resources
(Pdb) pkg_resources.get_distribution('collective.lazysizes').version
'3.0.0.dev0'
```
@jensens @hvelarde thanks for following up on this.

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/quickinstaller.py b/Products/CMFPlone/controlpanel/browser/quickinstaller.py
--- a/Products/CMFPlone/controlpanel/browser/quickinstaller.py
+++ b/Products/CMFPlone/controlpanel/browser/quickinstaller.py
@@ -556,6 +556,7 @@ def marshall_addons(self):
                     continue
                 addons[product_id] = {
                     'id': product_id,
+                    'version': self.get_product_version(product_id),
                     'title': product_id,
                     'description': '',
                     'upgrade_profiles': {},


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Plone 5 - the addons control panel no longer shows the addon version number



Discussion:
here is a screenshot:

![selection_013](https://cloud.githubusercontent.com/assets/341393/13792758/43c9be44-ead2-11e5-9204-bd6ee09c24a2.png)

This is still an issue.
I don't know how this information was obtained before, but I think this was lost at some point when we decide to get rid of the `portal_quickinstaller` tool.

as long as I see, profiles don't include version information:

```python
(Pdb) pp [p for p in profiles if p['title'] == 'collective.lazysizes']
[{'description': u' Integration of lazysizes, a lightweight lazy loader, into Plone.',
  'for': None,
  'id': u'collective.lazysizes:default',
  'path': u'/home/hvelarde/collective/lazysizes/src/collective/lazysizes/profiles/default',
  'post_handler': None,
  'pre_handler': None,
  'product': 'collective.lazysizes',
  'title': u'collective.lazysizes',
  'type': 2,
  'version': u'7'}]
```

probably we need to hack `portal_setup.listProfileInfo()` to include the information; any ideas @mauritsvanrees?

alternatively we can add a function to get the version number:

```python
(Pdb) import pkg_resources
(Pdb) pkg_resources.get_distribution('collective.lazysizes').version
'3.0.0.dev0'
```
@jensens @hvelarde thanks for following up on this.
For the record, this has nothing to do with the PLIP for getting rid of the `portal_quickinstaller`, which is new in 5.1. The versions are already gone in 5.0.  4.3 still shows them.

Anyway, it seems good to show them, and your pull request does that.

Maybe good to do that on 5.0 too?

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/quickinstaller.py b/Products/CMFPlone/controlpanel/browser/quickinstaller.py
--- a/Products/CMFPlone/controlpanel/browser/quickinstaller.py
+++ b/Products/CMFPlone/controlpanel/browser/quickinstaller.py
@@ -7,6 +7,7 @@
 from plone.memoize import view
 from zope.component import getAllUtilitiesRegisteredFor
 import logging
+import pkg_resources
 
 
 class ManageProductsView(BrowserView):
@@ -23,6 +24,18 @@ def __init__(self, *args, **kwargs):
     def __call__(self):
         return self.index()
 
+    def get_product_version(self, product_id):
+        """Return the version of the product (package).
+        From CMFQuickInstallerTool/QuickInstallerTool
+        getProductVersion
+        That implementation used to fall back to getting the version.txt.
+        """
+        try:
+            dist = pkg_resources.get_distribution(product_id)
+            return dist.version
+        except pkg_resources.DistributionNotFound:
+            return ''
+
     @view.memoize
     def marshall_addons(self):
         addons = {}
@@ -74,6 +87,7 @@ def marshall_addons(self):
 
                 addons[product_id] = {
                     'id': product_id,
+                    'version': self.get_product_version(product_id),
                     'title': product_id,
                     'description': '',
                     'product_file': product_file,


Test patch:
Repository: plone/Products.CMFPlone

Issue:
No validation is made on Twitter username
### What I did:

I added a `@` char to the Twitter user name in the Social Media configlet.

### What I expect to happen:

An validation error should be shown.

### What actually happened:

I was able to save the invalid user name.

![screen shot 2017-03-28 at 13 41 17](https://cloud.githubusercontent.com/assets/341393/24416789/4ffc193c-13bc-11e7-932b-0ea15d87246b.png)

### What version of Plone/ Addons I am using:

Plone 5.1b2


Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/interfaces/controlpanel.py b/Products/CMFPlone/interfaces/controlpanel.py
--- a/Products/CMFPlone/interfaces/controlpanel.py
+++ b/Products/CMFPlone/interfaces/controlpanel.py
@@ -5,6 +5,7 @@
 from zope import schema
 from zope.interface import implementer
 from zope.interface import Interface
+from zope.interface import Invalid
 from zope.schema.vocabulary import SimpleTerm
 from zope.schema.vocabulary import SimpleVocabulary
 
@@ -1457,6 +1458,13 @@ class IUserGroupsSettingsSchema(Interface):
     )
 
 
+def validate_twitter_username(value):
+    if value and value.startswith('@'):
+        raise Invalid(
+            u'Twitter username should not include the "@" prefix character.')
+    return True
+
+
 class ISocialMediaSchema(Interface):
 
     share_social_data = schema.Bool(
@@ -1467,10 +1475,15 @@ class ISocialMediaSchema(Interface):
         default=True)
 
     twitter_username = schema.ASCIILine(
-        title=_(u'Twitter Username'),
-        description=_(u'To identify things like Twitter Cards. Do not include the \'@\' prefix character.'),
+        title=_(u'Twitter username'),
+        description=_(
+            u'To identify things like Twitter Cards. '
+            u'Do not include the "@" prefix character.'
+        ),
         required=False,
-        default='')
+        default='',
+        constraint=validate_twitter_username,
+    )
 
     facebook_app_id = schema.ASCIILine(
         title=_(u'Facebook App ID'),


Test patch:
Repository: plone/Products.CMFPlone

Issue:
robots.txt contradicts sitemap.xml.gz for urls containing the string "search"
## BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)
<!--

Read https://plone.org/support/bugs first!

Please use the labels at Github, at least one of the types: bug, regression, question, enhancement.

Please include tracebacks, screenshots, code of debugging sessions or code that reproduces the issue if possible. 
The best reproductions are in plain Plone installations without addons or at least with minimal needed addons installed.

-->

### What I did:

Installed Plone 5.0.6 and created a folder called `Research`

### What I expect to happen:

I expected Google would index the contents.

### What actually happened:

Google search console threw an error: that the urls in that folder were in the
`sitemap.xml.gz`, but was Disallowed by `robots.txt`.

### What version of Plone/ Addons I am using:

Plone 5.0.6




See https://github.com/plone/Products.CMFPlone/commit/03a7670544add6c889ce72391f71f4775929418e



Discussion:
@CharString as mentioned in the commit, we're talking about 2 different issues here:

* we need to block robots from the search and search result pages and we need to find out the best way to do it without adding the `/*search` line in `robots.txt` as this is causing problems (maybe using a combination of the `X-Robots-Tag` HTTP response header and the `nofollow` value on listing links)
* we need to review why `sitemap.xml.gz` is pointing to the view instead of using the canonical URL

more information here: https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag

I can fix those things after the @plone/framework-team give me some clues on how to proceed.
@hvelarde I only mentioned the first in this issue description, and I've created a separate issue in the plone.app.layout for the views thing:
https://github.com/plone/plone.app.layout/issues/117

The simplest possible solution would be to replace the `/*search` line with 2
lines:

    Disallow: /search
    Disallow: /*@@search

That would correct the (first) issue at hand with Google (and possibly others that allow `*` syntax. The `X-Robots-Tag` (or a `<meta>`-tag in the `<head>` of the search templates) would be a completer solution, that expands the functionality of blocking search result pages to crawlers that implement the standard robots.txt (without `*`).


Resolving patch:
diff --git a/Products/CMFPlone/interfaces/controlpanel.py b/Products/CMFPlone/interfaces/controlpanel.py
--- a/Products/CMFPlone/interfaces/controlpanel.py
+++ b/Products/CMFPlone/interfaces/controlpanel.py
@@ -39,7 +39,7 @@
 Disallow: /*folder_summary_view$
 Disallow: /*login_form$
 Disallow: /*mail_password_form$
-Disallow: /*search
+Disallow: /@@search
 Disallow: /*search_rss$
 Disallow: /*sendto_form$
 Disallow: /*summary_view$


Test patch: