Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Testcase for #1366. Created a testcase and a crafted plugin to demons…

…trate the issue
  • Loading branch information...
commit 0897f8aa27e8bb9d25ed1476e6ae9e9cbf73c175 1 parent 1c9f83c
@yakky authored
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
28 cms/tests/placeholder.py
@@ -157,6 +157,34 @@ 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_placeholder_scanning_fail(self):
self.assertRaises(TemplateSyntaxError, get_placeholders, 'placeholder_tests/test_eleven.html')
Please sign in to comment.
Something went wrong with that request. Please try again.