From ecfc0714bc00b48b6dcfbf29099d0d1d8f4a56df Mon Sep 17 00:00:00 2001 From: Ben Knowles Date: Thu, 2 Jan 2020 14:33:57 -0600 Subject: [PATCH] fix: global search index breaking on long titles If you created a doc with a title longer than 140 characters, it's supposed to be truncated to 140. However, the global search index would break for that doctype due to an error in the query. The truncate was happening AFTER it was escaped, causing it to lose the closing quote mark which caused a SQL error and broke the index. --- frappe/utils/global_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/utils/global_search.py b/frappe/utils/global_search.py index 7012b737c0..20309559e3 100644 --- a/frappe/utils/global_search.py +++ b/frappe/utils/global_search.py @@ -137,8 +137,8 @@ def rebuild_for_doctype(doctype): "name": frappe.db.escape(doc.name), "content": frappe.db.escape(' ||| '.join(content or '')), "published": published, - "title": frappe.db.escape(title or '')[:int(frappe.db.VARCHAR_LEN)], - "route": frappe.db.escape(route or '')[:int(frappe.db.VARCHAR_LEN)] + "title": frappe.db.escape((title or '')[:int(frappe.db.VARCHAR_LEN)]), + "route": frappe.db.escape((route or '')[:int(frappe.db.VARCHAR_LEN)]) }) if all_contents: insert_values_for_multiple_docs(all_contents)