Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for icon_url escape #1416

Merged
merged 3 commits into from

3 participants

@yakky
Collaborator

Tests and fix for #1366

@travisbot

This pull request passes (merged c0f8606 into ceace95).

@digi604 digi604 merged commit 1e144b5 into divio:develop

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 29, 2012
  1. @yakky
  2. @yakky

    Added testcase for page objects for #1366. This issue doesn't apply t…

    yakky authored
    …o page-defined placeholders as codepath differs
Commits on Sep 5, 2012
  1. @yakky
This page is out of date. Refresh to see the latest.
View
2  cms/admin/placeholderadmin.py
@@ -225,7 +225,7 @@ def edit_plugin(self, request, plugin_id):
'name': unicode(saved_object),
"type": saved_object.get_plugin_name(),
'plugin_id': plugin_id,
- 'icon': force_escape(escapejs(saved_object.get_instance_icon_src())),
+ 'icon': force_escape(saved_object.get_instance_icon_src()),
'alt': force_escape(escapejs(saved_object.get_instance_icon_alt())),
}
return render_to_response('admin/cms/page/plugin_forms_ok.html', context, RequestContext(request))
View
16 cms/test_utils/project/placeholderapp/cms_plugins.py
@@ -0,0 +1,16 @@
+from cms.plugin_pool import plugin_pool
+from cms.plugin_base import CMSPluginBase
+from django.utils.translation import ugettext_lazy as _
+from django.conf import settings
+
+class EmptyPlugin(CMSPluginBase):
+ name = _("Test Plugin")
+ text_enabled = True
+
+ def render(self, context, instance, placeholder):
+ return context
+
+ def icon_src(self, instance):
+ return settings.STATIC_URL + u"plugins/empty-image-file.png"
+
+plugin_pool.register_plugin(EmptyPlugin)
View
46 cms/tests/placeholder.py
@@ -157,6 +157,52 @@ def test_inter_placeholder_plugin_move(self):
self.assertEqual([ph1_pl1, ph1_pl3], list(ph1.cmsplugin_set.order_by('position')))
self.assertEqual([ph2_pl1, ph1_pl2, ph2_pl2, ph2_pl3], list(ph2.cmsplugin_set.order_by('position')))
+ def test_nested_plugin_escapejs(self):
+ """
+ Checks #1366 error condition.
+ When adding/editing a plugin whose icon_src() method returns a URL
+ containing an hyphen, the hyphen is escaped by django escapejs resulting
+ in a incorrect URL
+ """
+ with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
+ ex = Example1(
+ char_1='one',
+ char_2='two',
+ char_3='tree',
+ char_4='four'
+ )
+ ex.save()
+ ph1 = ex.placeholder
+ ###
+ # add the test plugin
+ ###
+ test_plugin = add_plugin(ph1, u"EmptyPlugin", u"en")
+ test_plugin.save()
+ pl_url = "%sedit-plugin/%s/" % (
+ reverse('admin:placeholderapp_example1_change', args=(ex.pk,)),
+ test_plugin.pk)
+ response = self.client.post(pl_url, {})
+ self.assertContains(response,"/static/plugins/empty-image-file.png")
+
+ def test_nested_plugin_escapejs_page(self):
+ """
+ Sibling test of the above, on a page.
+ #1366 does not apply to placeholder defined in a page
+ """
+ with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
+ page = create_page('page', 'col_two.html', 'en')
+ ph1 = page.placeholders.get(slot='col_left')
+ ###
+ # add the test plugin
+ ###
+ test_plugin = add_plugin(ph1, u"EmptyPlugin", u"en")
+ test_plugin.save()
+ pl_url = "%sedit-plugin/%s/" % (
+ reverse('admin:cms_page_change', args=(page.pk,)),
+ test_plugin.pk)
+ response = self.client.post(pl_url, {})
+ self.assertContains(response,"/static/plugins/empty-image-file.png")
+
def test_placeholder_scanning_fail(self):
self.assertRaises(TemplateSyntaxError, get_placeholders, 'placeholder_tests/test_eleven.html')
Something went wrong with that request. Please try again.