fix: encode filename to handle special characters (#12478)

* fix: same as previous row treated as one doc

treat repeated parent doc rows as same doc(parent), because legacy system downloaded data with inner join will normally have repeat same content for the parent docs

* fix: attached url with utf8 characters file name e.g Chinese

fix attached file via URL in comment by file name with utf8 characters

* fix: revert as it is already in other PR

* refactor: use frappe.safe_encode

Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
This commit is contained in:
Fisher Yu 2021-03-11 16:57:37 +08:00 committed by GitHub
parent 5e5f470272
commit 8ef2545665
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -449,8 +449,8 @@ class ImportFile:
data_without_first_row = data[1:]
for row in data_without_first_row:
row_values = row.get_values(parent_column_indexes)
# if the row is blank or same content as the previous parent row, it's a child row doc
if all([v in INVALID_VALUES for v in row_values]) or row_values == parent_row_values:
# if the row is blank, it's a child row doc
if all([v in INVALID_VALUES for v in row_values]):
rows.append(row)
continue
# if we encounter a row which has values in parent columns,

View file

@ -75,7 +75,7 @@ class File(Document):
self.add_comment_in_reference_doc('Attachment',
_('Added {0}').format("<a href='{file_url}' target='_blank'>{file_name}</a>{icon}".format(**{
"icon": ' <i class="fa fa-lock text-warning"></i>' if self.is_private else "",
"file_url": quote(self.file_url) if self.file_url else self.file_name,
"file_url": quote(frappe.safe_encode(self.file_url)) if self.file_url else self.file_name,
"file_name": self.file_name or self.file_url
})))