Fix some (but not all) handling of tags with & via urlencoding.

This commit is contained in:
voussoir 2020-09-27 11:53:38 -07:00
parent e11f04342a
commit 705bd8269f
2 changed files with 9 additions and 9 deletions

View file

@ -522,20 +522,20 @@ function submit_search()
add_searchtag_from_box(input_forbids, inputted_forbids, "search_builder_forbids_inputted"); add_searchtag_from_box(input_forbids, inputted_forbids, "search_builder_forbids_inputted");
let has_tag_params = false; let has_tag_params = false;
const musts = simplify_tagnames(inputted_musts).join(","); const musts = simplify_tagnames(inputted_musts).map(encodeURIComponent).join(",");
if (musts) {parameters.push("tag_musts=" + musts); has_tag_params = true;} if (musts) {parameters.push("tag_musts=" + musts); has_tag_params = true;}
const mays = simplify_tagnames(inputted_mays).join(","); const mays = simplify_tagnames(inputted_mays).map(encodeURIComponent).join(",");
if (mays) {parameters.push("tag_mays=" + mays); has_tag_params = true;} if (mays) {parameters.push("tag_mays=" + mays); has_tag_params = true;}
const forbids = simplify_tagnames(inputted_forbids).join(","); const forbids = simplify_tagnames(inputted_forbids).map(encodeURIComponent).join(",");
if (forbids) {parameters.push("tag_forbids=" + forbids); has_tag_params = true;} if (forbids) {parameters.push("tag_forbids=" + forbids); has_tag_params = true;}
const expression = document.getElementsByName("tag_expression")[0].value; const expression = document.getElementsByName("tag_expression")[0].value;
if (expression) if (expression)
{ {
//expression = expression.replace(new RegExp(" ", 'g'), "-"); //expression = expression.replace(new RegExp(" ", 'g'), "-");
parameters.push("tag_expression=" + expression); parameters.push("tag_expression=" + encodeURIComponent(expression));
has_tag_params = true; has_tag_params = true;
} }
@ -667,7 +667,7 @@ const inputted_forbids = [];
{% set key="tag_" + tagtype %} {% set key="tag_" + tagtype %}
{% if search_kwargs[key] %} {% if search_kwargs[key] %}
{% for tag in search_kwargs[key] %} {% for tag in search_kwargs[key] %}
inputted_{{tagtype}}.push("{{tag.name}}"); inputted_{{tagtype}}.push("{{tag.name|safe}}");
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -25,10 +25,10 @@
) -%} ) -%}
{%- set href = { {%- set href = {
"search": "/search?tag_musts=" + tag.name, "search": "/search?tag_musts=" + (tag.name|urlencode),
"search_musts": "/search?tag_musts=" + tag.name, "search_musts": "/search?tag_musts=" + (tag.name|urlencode),
"search_mays": "/search?tag_mays=" + tag.name, "search_mays": "/search?tag_mays=" + (tag.name|urlencode),
"search_forbids": "/search?tag_forbids=" + tag.name, "search_forbids": "/search?tag_forbids=" + (tag.name|urlencode),
"info": "/tag/" + tag.name, "info": "/tag/" + tag.name,
None: None, None: None,
}.get(link, link) }.get(link, link)