Skip to content

Job board: job_detail page leaks HTML from description #2307

@enku

Description

@enku

Describe the bug
On the Jobs board detail page, HTML from the description "bleeds" into the <meta property="og:description" tag in the <head>. For an example, see https://www.python.org/jobs/7329/ (at the top of the page).

To Reproduce
Steps to reproduce the behavior:

  1. Go to any jobs detail page, one that has HTML in the description
  2. Look at the top of the page
  3. You'll see partial rendered HTML from the job description. It's being leaked out of the
    <meta property="og:description" tag.

Expected behavior
The top of the jobs detail page does not leak part of the job description.

Screenshots
image

Desktop (please complete the following information):

  • OS: (Gentoo) Linux
  • Browser: Firefox
  • Version: 117.0

Additional context
Possible fix:

diff --git a/templates/jobs/job_detail.html b/templates/jobs/job_detail.html
index 82ddd3f..12c204a 100644
--- a/templates/jobs/job_detail.html
+++ b/templates/jobs/job_detail.html
@@ -8,7 +8,7 @@
 {% block content_attributes %}with-right-sidebar{% endblock %}
 
 {% block og_title %}Job: {{ object.job_title }} at {{ object.company_name }}{% endblock %}
-{% block og-descript %}{{ object.description|truncatechars:200 }}{% endblock %}
+{% block og-descript %}{{ object.description|striptags|truncatechars:200 }}{% endblock %}
 
 {% block content %}
 {% load companies %}

Activity

Mubeen-Ul-Hassan

Mubeen-Ul-Hassan commented on Oct 9, 2023

@Mubeen-Ul-Hassan

Hi,

I tried to fix and I have fixed it but not very sure until it doesn't deploy and run. Can you guide me a little on how to check it I run that file on Firefox but doesn't look as it should.

Screenshot (102)

hugovk

hugovk commented on Oct 9, 2023

@hugovk
Member

There are detailed instructions on how to set up with Docker at https://pythondotorg.readthedocs.io/install.html

added a commit that references this issue on Oct 13, 2023
75ae6fe
linked a pull request that will close this issue on Oct 13, 2023
added
frontendRelates to the frontend of the app
app/jobsRelates to the jobs app
help-wantedThe maintainers would welcome help with this issue
on Sep 17, 2024
added a commit that references this issue on Jan 22, 2025
6496599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/jobsRelates to the jobs appfrontendRelates to the frontend of the apphelp-wantedThe maintainers would welcome help with this issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @enku@hugovk@JacobCoffee@Mubeen-Ul-Hassan

      Issue actions

        Job board: job_detail page leaks HTML from description · Issue #2307 · python/pythondotorg