[note] [fix] strip invalid characters from title and set it as the name of the note
diff --git a/patches/may_2013/p06_make_notes.py b/patches/may_2013/p06_make_notes.py
index e1ea656..b9dbca1 100644
--- a/patches/may_2013/p06_make_notes.py
+++ b/patches/may_2013/p06_make_notes.py
@@ -2,6 +2,8 @@
def execute():
webnotes.reload_doc("utilities", "doctype", "note")
+ webnotes.reload_doc("utilities", "doctype", "note_user")
+
for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
name = question.question[:180]
if webnotes.conn.exists("Note", name):
diff --git a/utilities/doctype/note/note.py b/utilities/doctype/note/note.py
index beca241..02862de 100644
--- a/utilities/doctype/note/note.py
+++ b/utilities/doctype/note/note.py
@@ -7,6 +7,11 @@
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
+ def autoname(self):
+ # replace forbidden characters
+ import re
+ self.doc.name = re.sub("[%'\"#*?`]", "", self.doc.title.strip())
+
def onload(self):
if not self.doc.public and webnotes.session.user != self.doc.owner:
if webnotes.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]:
diff --git a/utilities/doctype/note/note.txt b/utilities/doctype/note/note.txt
index d14ecf7..a6cdf2b 100644
--- a/utilities/doctype/note/note.txt
+++ b/utilities/doctype/note/note.txt
@@ -2,14 +2,13 @@
{
"creation": "2013-05-24 13:41:00",
"docstatus": 0,
- "modified": "2013-05-24 16:47:19",
+ "modified": "2013-05-27 12:16:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_print": 0,
"allow_rename": 1,
- "autoname": "field:title",
"description": "Note is a free page where users can share documents / notes",
"doctype": "DocType",
"document_type": "Transaction",