def test_xss_arguments_and_escaping(self): addon = Addon.objects.get() addon.name = 'Delicious <script src="x.js">Bookmarks' addon.save() addon = addon.reload() au = AddonUser(addon=addon, user=self.user) amo.log(amo.LOG.CHANGE_USER_WITH_ROLE, au.user, au.get_role_display(), addon) log = ActivityLog.objects.get() log_expected = ('yolo role changed to Owner for <a href="/en-US/' 'firefox/addon/a3615/">Delicious <script src=' '"x.js">Bookmarks</a>.') eq_(log.to_string(), log_expected) eq_(jingo.env.from_string('<p>{{ log }}</p>').render({'log': log}), '<p>%s</p>' % log_expected)
def test_xss_arguments_and_escaping(self): addon = Addon.objects.get() addon.name = 'Delicious <script src="x.js">Bookmarks' addon.save() addon = addon.reload() au = AddonUser(addon=addon, user=self.user) ActivityLog.create(amo.LOG.CHANGE_USER_WITH_ROLE, au.user, six.text_type(au.get_role_display()), addon) log = ActivityLog.objects.get() log_expected = ('Yolo role changed to Owner for <a href="/en-US/' 'firefox/addon/a3615/">Delicious <script src=' '"x.js">Bookmarks</a>.') assert log.to_string() == log_expected rendered = amo.utils.from_string('<p>{{ log }}</p>').render( {'log': log}) assert rendered == '<p>%s</p>' % log_expected
def test_xss_arguments_and_escaping(self): addon = Addon.objects.get() addon.name = 'Delicious <script src="x.js">Bookmarks' addon.save() addon = addon.reload() au = AddonUser(addon=addon, user=self.user) ActivityLog.create( amo.LOG.CHANGE_USER_WITH_ROLE, au.user, six.text_type(au.get_role_display()), addon) log = ActivityLog.objects.get() log_expected = ('Yolo role changed to Owner for <a href="/en-US/' 'firefox/addon/a3615/">Delicious <script src=' '"x.js">Bookmarks</a>.') assert log.to_string() == log_expected rendered = amo.utils.from_string('<p>{{ log }}</p>').render( {'log': log}) assert rendered == '<p>%s</p>' % log_expected
def create_addon(self, license=None): data = self.cleaned_data a = Addon(guid=data['guid'], name=data['name'], type=data['type'], status=amo.STATUS_UNREVIEWED, homepage=data['homepage'], summary=data['summary']) a.save() AddonUser(addon=a, user=self.request.user).save() self.addon = a # Save Version, attach License self.create_version(license=license) amo.log(amo.LOG.CREATE_ADDON, a) log.info('Addon %d saved' % a.id) return a
'"{1}" language pack'.format(data['version'], xpi)) return if (Addon.objects.filter( name__localized_string=data['name']).exists()): data['old_name'] = data['name'] data['name'] = u'{0} ({1})'.format( data['old_name'], data['apps'][0].appdata.pretty) log.warning(u'[@None] Creating langpack {guid}: Add-on with ' u'name {old_name!r} already exists, trying ' u'{name!r}.'.format(**data)) addon = Addon.from_upload(upload, [amo.PLATFORM_ALL.id], parsed_data=data) AddonUser(addon=addon, user=owner).save() version = addon.versions.get() if addon.default_locale.lower() == lang.lower(): addon.target_locale = addon.default_locale addon.save() log.info( '[@None] Created new "{0}" language pack, version {1}'.format( xpi, data['version'])) # Set the category for app in version.compatible_apps: static_category = (CATEGORIES.get(app.id, []).get(amo.ADDON_LPAPP,