fix: broken links in get_desk_link with special chars (#33730)

* fix: broken links in get_desk_link with special chars

* fix: pass both encoded_name (for href) and name (for display)

---------

Co-authored-by: rehansari26 <rehan.ansari@cloverinfotech.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Rehan Ansari 2025-08-26 18:05:46 +05:30 committed by GitHub
parent 7f7405788c
commit f775b0b88e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1473,18 +1473,28 @@ def logger(
def get_desk_link(doctype, name, show_title_with_name=False, open_in_new_tab=False):
from urllib.parse import quote
meta = get_meta(doctype)
title = get_value(doctype, name, meta.get_title_field())
target_attr = ' target="_blank"' if open_in_new_tab else ""
# encode for href
encoded_name = quote(name)
if show_title_with_name and name != title:
html = '<a href="/app/Form/{doctype}/{name}"{target} style="font-weight: bold;">{doctype_local} {name}: {title_local}</a>'
html = '<a href="/app/Form/{doctype}/{encoded_name}"{target} style="font-weight: bold;">{doctype_local} {name}: {title_local}</a>'
else:
html = '<a href="/app/Form/{doctype}/{name}"{target} style="font-weight: bold;">{doctype_local} {title_local}</a>'
html = '<a href="/app/Form/{doctype}/{encoded_name}"{target} style="font-weight: bold;">{doctype_local} {title_local}</a>'
return html.format(
doctype=doctype, name=name, doctype_local=_(doctype), title_local=_(title), target=target_attr
doctype=doctype,
name=name,
encoded_name=encoded_name,
doctype_local=_(doctype),
title_local=_(title),
target=target_attr,
)