[fix] Removes ``/>`` ending tags for void HTML elements

Removes ``/>`` ending tags for void elements [1] and replaces them with ``>``.
Part of the larger cleanup to cleanup invalid HTML throughout the codebase [2].

[1] https://html.spec.whatwg.org/multipage/syntax.html#void-elements
[2] https://github.com/searxng/searxng/issues/3793
This commit is contained in:
Grant Lanham 2024-09-10 21:44:30 -04:00 committed by Markus Heiser
parent 28dc623785
commit 0b832f19bf
11 changed files with 25 additions and 26 deletions

View File

@ -84,9 +84,9 @@ HTML of the site. URL of the SearXNG instance and values are customizable.
.. code:: html .. code:: html
<form method="post" action="https://example.org/"> <form method="post" action="https://example.org/">
<!-- search --> <input type="text" name="q" /> <!-- search --> <input type="text" name="q">
<!-- categories --> <input type="hidden" name="categories" value="general,social media" /> <!-- categories --> <input type="hidden" name="categories" value="general,social media">
<!-- language --> <input type="hidden" name="lang" value="all" /> <!-- language --> <input type="hidden" name="lang" value="all">
<!-- locale --> <input type="hidden" name="locale" value="en" /> <!-- locale --> <input type="hidden" name="locale" value="en">
<!-- date filter --> <input type="hidden" name="time_range" value="month" /> <!-- date filter --> <input type="hidden" name="time_range" value="month">
</form> </form>

View File

@ -28,7 +28,7 @@ And in the HTML template from flask a stylesheet link is needed (the value of
<link rel="stylesheet" <link rel="stylesheet"
href="{{ url_for('client_token', token=link_token) }}" href="{{ url_for('client_token', token=link_token) }}"
type="text/css" /> type="text/css" >
.. _X-Forwarded-For: .. _X-Forwarded-For:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

View File

@ -54,7 +54,6 @@ def response(resp):
excerpt = result.xpath('.//div[@class="torrent_excerpt"]')[0] excerpt = result.xpath('.//div[@class="torrent_excerpt"]')[0]
content = html.tostring(excerpt, encoding='unicode', method='text', with_tail=False) content = html.tostring(excerpt, encoding='unicode', method='text', with_tail=False)
# it is better to emit <br/> instead of |, but html tags are verboten
content = content.strip().replace('\n', ' | ') content = content.strip().replace('\n', ' | ')
content = ' '.join(content.split()) content = ' '.join(content.split())

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="no-js theme-{{ preferences.get_value('simple_style') or 'auto' }} center-aligment-{{ preferences.get_value('center_alignment') and 'yes' or 'no' }}" lang="{{ locale_rfc5646 }}" {% if rtl %} dir="rtl"{% endif %}> <html class="no-js theme-{{ preferences.get_value('simple_style') or 'auto' }} center-aligment-{{ preferences.get_value('center_alignment') and 'yes' or 'no' }}" lang="{{ locale_rfc5646 }}" {% if rtl %} dir="rtl"{% endif %}>
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8">
<meta name="description" content="SearXNG — a privacy-respecting, open metasearch engine"> <meta name="description" content="SearXNG — a privacy-respecting, open metasearch engine">
<meta name="keywords" content="SearXNG, search, search engine, metasearch, meta search"> <meta name="keywords" content="SearXNG, search, search engine, metasearch, meta search">
<meta name="generator" content="searxng/{{ searx_version }}"> <meta name="generator" content="searxng/{{ searx_version }}">
@ -13,23 +13,23 @@
<title>{% block title %}{% endblock %}{{ instance_name }}</title> <title>{% block title %}{% endblock %}{{ instance_name }}</title>
{% block meta %}{% endblock %} {% block meta %}{% endblock %}
{% if rtl %} {% if rtl %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/searxng-rtl.min.css') }}" type="text/css" media="screen" /> <link rel="stylesheet" href="{{ url_for('static', filename='css/searxng-rtl.min.css') }}" type="text/css" media="screen">
{% else %} {% else %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/searxng.min.css') }}" type="text/css" media="screen" /> <link rel="stylesheet" href="{{ url_for('static', filename='css/searxng.min.css') }}" type="text/css" media="screen">
{% endif %} {% endif %}
{% if get_setting('server.limiter') or get_setting('server.public_instance') %} {% if get_setting('server.limiter') or get_setting('server.public_instance') %}
<link rel="stylesheet" href="{{ url_for('client_token', token=link_token) }}" type="text/css" /> <link rel="stylesheet" href="{{ url_for('client_token', token=link_token) }}" type="text/css">
{% endif %} {% endif %}
{% block styles %}{% endblock %} {% block styles %}{% endblock %}
<!--[if gte IE 9]>--> <!--[if gte IE 9]>-->
<script src="{{ url_for('static', filename='js/searxng.head.min.js') }}" client_settings="{{ client_settings }}"></script> <script src="{{ url_for('static', filename='js/searxng.head.min.js') }}" client_settings="{{ client_settings }}"></script>
<!--<![endif]--> <!--<![endif]-->
{% block head %} {% block head %}
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/> <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}">
{% endblock %} {% endblock %}
<link rel="icon" href="{{ url_for('static', filename='img/favicon.png') }}" sizes="any"> <link rel="icon" href="{{ url_for('static', filename='img/favicon.png') }}" sizes="any">
<link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml"> <link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
<link rel="apple-touch-icon" href="{{ url_for('static', filename='img/favicon.png') }}"/> <link rel="apple-touch-icon" href="{{ url_for('static', filename='img/favicon.png') }}">
</head> </head>
<body class="{{ endpoint }}_endpoint" > <body class="{{ endpoint }}_endpoint" >
<main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}" class="{{body_class}}"> <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}" class="{{body_class}}">
@ -65,7 +65,7 @@
</main> </main>
<footer> <footer>
<p> <p>
{{ _('Powered by') }} <a href="{{ url_for('info', pagename='about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, open metasearch engine') }}<br/> {{ _('Powered by') }} <a href="{{ url_for('info', pagename='about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, open metasearch engine') }}<br>
<a href="{{ searx_git_url }}">{{ _('Source code') }}</a> <a href="{{ searx_git_url }}">{{ _('Source code') }}</a>
| <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a> | <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a>
{% if enable_metrics %}| <a href="{{ url_for('stats') }}">{{ _('Engine stats') }}</a>{% endif %} {% if enable_metrics %}| <a href="{{ url_for('stats') }}">{{ _('Engine stats') }}</a>{% endif %}

View File

@ -16,7 +16,7 @@
{%- if not search_on_category_select or not display_tooltip -%} {%- if not search_on_category_select or not display_tooltip -%}
{%- for category in categories -%} {%- for category in categories -%}
<div class="category category_checkbox">{{- '' -}} <div class="category category_checkbox">{{- '' -}}
<input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}"{% if category in selected_categories %} checked="checked"{% endif %}/> <input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}"{% if category in selected_categories %} checked="checked"{% endif %}>
<label for="checkbox_{{ category|replace(' ', '_') }}" class="tooltips"> <label for="checkbox_{{ category|replace(' ', '_') }}" class="tooltips">
{{- icon_big(category_icons[category]) if category in category_icons else icon_big('globe-outline') -}} {{- icon_big(category_icons[category]) if category in category_icons else icon_big('globe-outline') -}}
<div class="category_name">{{- _(category) -}}</div> <div class="category_name">{{- _(category) -}}</div>

View File

@ -38,7 +38,7 @@
<input type="hidden" name="safesearch" value="{{ safesearch }}"> <input type="hidden" name="safesearch" value="{{ safesearch }}">
<input type="hidden" name="theme" value="{{ theme }}"> <input type="hidden" name="theme" value="{{ theme }}">
{%- if timeout_limit -%}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{%- endif -%} {%- if timeout_limit -%}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{%- endif -%}
<input type="submit" value="{{ suggestion }}" /> <input type="submit" value="{{ suggestion }}">
</form> </form>
{%- endfor -%} {%- endfor -%}
</div> </div>

View File

@ -6,7 +6,7 @@
{%- endmacro -%} {%- endmacro -%}
{%- macro tab_header(name, id, label, checked) -%} {%- macro tab_header(name, id, label, checked) -%}
<input type="radio" name="{{ name }}" id="tab-{{ id }}" {% if checked is sameas true %}checked="checked"{% endif %} /> <input type="radio" name="{{ name }}" id="tab-{{ id }}" {% if checked is sameas true %}checked="checked"{% endif %}>
<label id="tab-label-{{ id }}" for="tab-{{ id }}" role="tab" aria-controls="tab-content-{{ id }}">{{ label }}</label> <label id="tab-label-{{ id }}" for="tab-{{ id }}" role="tab" aria-controls="tab-content-{{ id }}">{{ label }}</label>
<section id="tab-content-{{ id }}" role="tabpanel" aria-labelledby="tab-label-{{ id }}" aria-hidden="false"> <section id="tab-content-{{ id }}" role="tabpanel" aria-labelledby="tab-label-{{ id }}" aria-hidden="false">
{%- endmacro -%} {%- endmacro -%}
@ -23,7 +23,7 @@
{%- if checked == '?' -%} {%- if checked == '?' -%}
{{- icon_small('warning') -}} {{- icon_small('warning') -}}
{%- else -%} {%- else -%}
<input type="checkbox" {%- if name %} name="{{ name }}" {%- endif %} value="None" {%- if checked %} checked {%- endif -%}{%- if disabled %} disabled {%- endif -%}/> <input type="checkbox" {%- if name %} name="{{ name }}" {%- endif %} value="None" {%- if checked %} checked {%- endif -%}{%- if disabled %} disabled {%- endif -%}>
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
@ -33,7 +33,7 @@
id="{{ name }}" {{- ' ' -}} id="{{ name }}" {{- ' ' -}}
aria-labelledby="pref_{{ name }}"{{- ' ' -}} aria-labelledby="pref_{{ name }}"{{- ' ' -}}
class="checkbox-onoff reversed-checkbox"{{- ' ' -}} class="checkbox-onoff reversed-checkbox"{{- ' ' -}}
{%- if checked -%} checked{%- endif -%}/> {%- if checked -%} checked{%- endif -%}>
{%- endmacro -%} {%- endmacro -%}
{%- macro plugin_preferences(section) -%} {%- macro plugin_preferences(section) -%}

View File

@ -1,7 +1,7 @@
<p class="text-muted"> <p class="text-muted">
{{- _('This is the list of cookies and their values SearXNG is storing on your computer.') }} {{- _('This is the list of cookies and their values SearXNG is storing on your computer.') }}
<br />{{- _('With that list, you can assess SearXNG transparency.') -}} <br>{{- _('With that list, you can assess SearXNG transparency.') -}}
<br />{{- '' -}} <br>{{- '' -}}
</p> </p>
{% if cookies %} {% if cookies %}
<table class="cookies"> <table class="cookies">

View File

@ -1,9 +1,9 @@
<p class="small_font"> <p class="small_font">
{{- _('These settings are stored in your cookies, this allows us not to store this data about you.') -}} {{- _('These settings are stored in your cookies, this allows us not to store this data about you.') -}}
<br />{{- _("These cookies serve your sole convenience, we don't use these cookies to track you.") -}} <br>{{- _("These cookies serve your sole convenience, we don't use these cookies to track you.") -}}
</p>{{- '' -}} </p>{{- '' -}}
<input type="submit" value="{{ _('Save') }}" />{{- '' -}} <input type="submit" value="{{ _('Save') }}">{{- '' -}}
<div class="{% if rtl %}left{% else %}right{% endif %} preferences_back">{{- '' -}} <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back">{{- '' -}}
<a href="{{ url_for('clear_cookies') }}">{{ _('Reset defaults') }}</a>{{- '' -}} <a href="{{ url_for('clear_cookies') }}">{{ _('Reset defaults') }}</a>{{- '' -}}

View File

@ -18,12 +18,12 @@
<span itemprop="streetAddress"> <span itemprop="streetAddress">
{%- if result.address.house_number -%}{{- result.address.house_number -}}, {% endif %} {%- if result.address.house_number -%}{{- result.address.house_number -}}, {% endif %}
{{- result.address.road -}} {{- result.address.road -}}
</span><br/> </span><br>
{%- endif %} {%- endif %}
{%- if result.address.locality -%} {%- if result.address.locality -%}
<span itemprop="addressLocality">{{- result.address.locality -}}</span> <span itemprop="addressLocality">{{- result.address.locality -}}</span>
{%- if result.address.postcode -%}, <span itemprop="postalCode">{{- result.address.postcode -}}</span>{% endif %} {%- if result.address.postcode -%}, <span itemprop="postalCode">{{- result.address.postcode -}}</span>{% endif %}
<br/> <br>
{%- endif -%} {%- endif -%}
{%- if result.address.country -%} {%- if result.address.country -%}
<span itemprop="addressCountry">{{- result.address.country -}}</span> <span itemprop="addressCountry">{{- result.address.country -}}</span>

View File

@ -3,7 +3,7 @@
{% macro engine_data_form(engine_data) -%} {% macro engine_data_form(engine_data) -%}
{% for engine_name, kv_data in engine_data.items() %} {% for engine_name, kv_data in engine_data.items() %}
{% for k, v in kv_data.items() %} {% for k, v in kv_data.items() %}
<input type="hidden" name="engine_data-{{ engine_name }}-{{ k|e }}" value="{{ v|e }}" /> <input type="hidden" name="engine_data-{{ engine_name }}-{{ k|e }}" value="{{ v|e }}">
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{%- endmacro %} {%- endmacro %}