Skip to content

Commit

Permalink
RSS search fix (#3) (#4)
Browse files Browse the repository at this point in the history
* Fix RSS Feeds

* Handle author_string

* sanitize user input

---------

Co-authored-by: Jovanka <[email protected]>
  • Loading branch information
JGulic and Jovanka authored Sep 2, 2024
1 parent 242e320 commit a88e724
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Development

## [0.1.10](https://github.com/berlinonline/ckanext-datasetsnippets/releases/tag/0.1.10)

_(2024-09-02)_

- Sanitize user input & handle author_string/author

## [0.1.9](https://github.com/berlinonline/ckanext-datasetsnippets/releases/tag/0.1.9)

_(2024-08-29)_
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datasetsnippets/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9
0.1.10
14 changes: 11 additions & 3 deletions ckanext/datasetsnippets/blueprints/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,23 @@ def custom():
fields = request.params.get(u'fields', u'')
fq = u''
search_params = {}
# some facets are not with the name used in CKAN
changed_facets = {'author_string': 'author'}

for (param, value) in request.params.items():
if param not in [u'q', u'page', u'sort'] \
and len(value) and not param.startswith(u'_'):
if param == 'fq':
value_tmp = value.split('&')
result_dict = dict(pair.split('=') for pair in value_tmp)
for res in result_dict:
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res, result_dict[res])
if res in changed_facets.keys():
res_tmp = changed_facets[res]
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res_tmp, result_dict[res])
else:
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res, result_dict[res])
else:
search_params[param] = value
fq += u' %s:%s' % (param, value)
Expand Down Expand Up @@ -508,7 +516,7 @@ def _create_rss_id(resource_path, authority_name=None, date_string=None):

# Construct the GUID as a full URL
if authority_name:
return f"http://{authority_name}{resource_path}"
return f"https://{authority_name}{resource_path}"
else:
# Fallback to just the resource path if authority_name is not available
return resource_path
Expand Down
4 changes: 3 additions & 1 deletion ckanext/datasetsnippets/blueprints/snippet_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import ckan.plugins as plugins
from ckan.plugins import toolkit
from ckan.common import _, c, request, config
from six.moves.urllib.parse import unquote

from ckanext.datasetsnippets.blueprints import feeds

Expand Down Expand Up @@ -156,7 +157,8 @@ def search_dataset():
if k != 'root_breadcrumb']

# unicode format (decoded from utf8)
q = c.q = request.params.get('q', u'')
q = request.params.get('q', u'')
c.q = unquote(q)
c.query_error = False
page = h.get_page_number(request.params)

Expand Down

0 comments on commit a88e724

Please sign in to comment.