Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 CDP Browsable API doesn't return valid DAD-IS link with spaces in breed_name #16

Open
bunop opened this issue Oct 19, 2020 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@bunop
Copy link
Member

bunop commented Oct 19, 2020

An entry with spaces in URLField (such the dadis_url attribute at https://api.image2020genebank.eu/backend/dadis_link/1/) doesn't render correctly URLs with encoded spaces in templates. This beaviour seems depends by the urlize template tags, which is called in rest_framework/templates/rest_framework/base.html to render a string formatted like this (not a JSON but a <pre> formatted text):

{
    "url": "http://localhost:26081/backend/dadis_link/1/",
    "species": {
        "scientific_name": "Ovis aries",
        "common_name": "Sheep"
    },
    "supplied_breed": "Schoonebeek heath",
    "country": "Netherlands",
    "most_common_name": "Schoonebeeker Heideschaap",
    "transboundary_name": "Schoonebeek heath sheep",
    "other_name": [],
    "dadis_url": "https://fao-dadis-breed-detail.firebaseapp.com/?country=Netherlands&specie=Sheep&breed=Schoonebeeker%20Heideschaap",           
    "is_custom": true
}

more precisely, urlize cant represent the encoded space %20 in the href link:

from django.utils.html import urlize
urlize("https://fao-dadis-breed-detail.firebaseapp.com/?country=Netherlands&specie=Sheep&breed=Schoonebeeker%20Heideschaap")
# '<a href="https://fao-dadis-breed-detail.firebaseapp.com/?country=Netherlands&amp;specie=Sheep&amp;breed=Schoonebeeker+Heideschaap">https://fao-dadis-breed-detail.firebaseapp.com/?country=Netherlands&specie=Sheep&breed=Schoonebeeker%20Heideschaap</a>'

The returned link (in which %20 is changed in +) is not a valid dad-is permalink

@bunop bunop added bug Something isn't working enhancement New feature or request labels Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant