Skip to content

Commit

Permalink
protect against xss atack
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya-Oladazimi committed Jun 1, 2022
1 parent 8c8b665 commit ea7abc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ckanext/dataset_reference/controllers/link_reference.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# encoding: utf-8

from flask import redirect, request, render_template
from flask import redirect, request, render_template, Markup, escape
from sqlalchemy.sql.expression import false, true
from sqlalchemy.sql.operators import all_op
from yaml import Mark
import ckan.lib.helpers as h
import ckan.plugins.toolkit as toolkit
from ckanext.dataset_reference.models.package_reference_link import PackageReferenceLink
Expand Down Expand Up @@ -89,6 +90,8 @@ def get_publication(name):
return_rows += Helper.create_table_row(meta_data, source.id, Helper.check_access_edit_package(package['id']))

if return_rows != "":
return_rows = return_rows.replace("<script>", "")
return_rows = return_rows.replace("</script>", "")
return return_rows

return '0'
Expand Down
3 changes: 2 additions & 1 deletion ckanext/dataset_reference/libs/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ckanext.dataset_reference.libs.citation_formatter import CitationFromatter
from datetime import datetime as _time
from bibtexparser.bparser import BibTexParser
from flask import Markup


Base_doi_api_url = "http://dx.doi.org/"
Expand Down Expand Up @@ -444,7 +445,7 @@ def get_month_list():
'''
def create_table_row(meta_data, object_id, is_auth_to_delete):
row = '<tr>'
row = row + '<td>' + meta_data['cite'] + '</td>'
row = row + '<td>' + Markup.striptags(meta_data['cite']) + '</td>'
if meta_data['link'] and meta_data['link'] != '':
row = row + '<td><a href="' + meta_data['link'] + '" target="_blank">Link</a></td>'
else:
Expand Down

0 comments on commit ea7abc2

Please sign in to comment.