Commit graph

137 commits

Author SHA1 Message Date
Aarol D'Souza
08793c57f7
fix: force type check in whitelisted methods 2 (#37086)
* fix(diff): add type hints to whitelisted methods

* fix(global_search): add type hints to whitelisted methods

* fix(custom_html_block): add type hints to whitelisted methods

* fix(deleted_document): add type hints to whitelisted methods

* fix(log_settings): add type hints to whitelisted methods

* fix(role): add type hints to whitelisted methods

* fix(user_type): add type hints to whitelisted methods

* fix(rq_job): add type hints to whitelisted methods

* fix(link_preview): add type hints to whitelisted methods

* fix(email_account): add type hints to whitelisted methods

* fix(web_form): add type hints to whitelisted methods

* fix(web_page_view): add type hints to whitelisted methods

* fix(csvutils): add type hints to whitelisted methods

* fix(file_manager): add type hints to whitelisted methods

* fix(email_body): add type hints to whitelisted methods

* fix(email_queue): add type hints to whitelisted methods

* fix(email_template): add type hints to whitelisted methods

* fix(notification): add type hints to whitelisted methods

* fix(email_group): add type hints to whitelisted methods

* fix(inbox): add type hints to whitelisted methods

* fix(recorder): add type hints to whitelisted methods

* fix(sms_settings): add type hints to whitelisted methods

* fix: tighten type hints

* fix(data_import): add type hints to whitelisted methods

* fix(user_permission): add type hints to whitelisted methods

* fix(gantt): add type hints to whitelisted methods

* fix(like): add type hints to whitelisted methods

* fix(search): add type hints to whitelisted methods

* fix(onboarding_step): add type hints to whitelisted methods

* fix(system_console): add type hints to whitelisted methods

* fix(workspace_sidebar): add type hints to whitelisted methods

* fix(todo): add type hints to whitelisted methods

* fix: correct type hints

* fix(print_format): add type hints to whitelisted methods

* fix(client): add type hints to whitelisted methods
2026-02-19 14:58:16 +05:30
Safwan Samsudeen
03bff35b5e chore: pre-commit 2025-08-25 13:23:32 +05:30
Safwan Samsudeen
6131aa63fd fix: allow all internal urls 2025-08-25 11:00:55 +05:30
Safwan Samsudeen
adc477f255 feat: tweak to allow drive links 2025-08-22 14:54:24 +05:30
gavin
a71df1839f
fix: Drop file_manager.download_file (#26575)
Closes https://github.com/frappe/frappe/issues/26424
2024-05-27 19:30:48 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
1e20820846
refactor: Indicate that weak hash functions are not usedforsecurity (#23540)
[skip ci]
2023-12-01 16:04:37 +05:30
Akhil Narang
fbc88a4d24
refactor(treewide): code cleanup
Drop redundant bool conversion

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-23 13:57:51 +05:30
Ankush Menat
56640a0723 fix: support symlinked and /files directory
Easiest way to move site/files or site/private directories is to symlink
them, the validation for file path was failing because it resolves only
until site path.

Resolving real path doesn't seem to be _REALLY_ required here.
2022-11-01 13:25:21 +05:30
Ankush Menat
f0ab6cb488
Revert "fix: use is_file_path_valid instead of is_safe_path (#18316)" (#18688)
This reverts commit d35aa6c545.
2022-11-01 12:40:54 +05:30
Sagar Vora
d35aa6c545
fix: use is_file_path_valid instead of is_safe_path (#18316)
* fix: use `validate_file_path` instead of `is_safe_path`

* test: specify `is_private` for file with private URL
2022-10-28 13:56:24 +05:30
Ankush Menat
45645c3f73 feat: consistent, translatable timeline messages (#17526)
reapply accidentally reverted commit

[skip ci]
2022-10-12 22:27:04 +05:30
Ankush Menat
ab3f706948 Revert "feat: consistent, translatable timeline messages (#17526)"
This reverts commit 112c492f3e.
2022-10-12 18:03:57 +05:30
Raffael Meyer
112c492f3e
feat: consistent, translatable timeline messages (#17526)
* feat: consistent, translatable timeline messages

* fix: save only filename for attachment comments

The rest of the comment will be added and translated ad-hoc by form_timeline.js

* patch: clean up Comments of type "Attachment"

* feat: further message types

* style: format with prettier

* test: cypress timeline

Timeline now correctly displays "You ..." instead of "{User} ..."

* feat: german transations for timeline comments

* fix: enable auto_commit_on_many_writes

* fix: don't update modified timestamp in patch
2022-10-06 16:05:34 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
5ec2690160 Merge branch 'develop' into refactor-file 2022-06-01 15:47:55 +05:30
chillaranand
25f82e966c refactor: Remove unused imports & code 2022-05-19 15:34:35 +05:30
Gavin D'souza
97e911e069 Merge branch 'develop' of github.com:frappe/frappe into refactor-file 2022-04-13 10:49:26 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Gavin D'souza
1728db8428 fix(file_manager): Correct and => or usage in refactored query 2022-04-01 17:50:33 +05:30
Gavin D'souza
d0bd4730da refactor(file_manager): Refactor raw SQLs to use qb & db_query APIs 2022-03-31 16:12:54 +05:30
Gavin D'souza
3110c42b80 fix(utils): URLs to return True via is_safe_path checks 2022-03-15 19:39:47 +05:30
Gavin D'souza
9b54e3d0c0 fix: Disallow sites to have file access beyond site folder 2022-03-15 19:39:47 +05:30
Gavin D'souza
b56e6fe4db fix: Safe decode base64 data in case of incorrect padding
This could possibly happen in case of corrupted/partial files. But for
the most part, if there's a missing trailing = or three at the end too.

Traceback:
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 67, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1208, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 307, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 239, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 499, in _validate
    self._extract_images_from_text_editor()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 983, in _extract_images_from_text_editor
    extract_images_from_doc(self, df.fieldname)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 779, in extract_images_from_doc
    content = extract_images_from_html(doc, content)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 822, in extract_images_from_html
    content = re.sub(r']*src\s*=\s*["\'](?=data:)(.*?)["\']', _save_file, content)
  File "/home/frappe/frappe-bench/env/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 814, in _save_file
    _file.save(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 307, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in insert
    self.run_method("before_insert")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 860, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1158, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1141, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 854, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 56, in before_insert
    self.save_file(content=self.content, decode=self.decode)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 436, in save_file
    self.content = base64.b64decode(self.content)
  File "/home/frappe/frappe-bench/env/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
2021-12-21 14:57:09 +05:30
rohitwaghchaure
6ae352a05f
fix: ignore filename with dotted path (#14617)
* fix: ignore dotted path in file name

* fix: condition for checking file

* Update data.py

* fix: only allow pdf files

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2021-10-28 19:23:57 +00:00
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Suraj Shetty
44c82276e8 refactor: Remove unused methods 2021-08-19 17:37:01 +05:30
Suraj Shetty
a7fb1816aa refactor: Remove unused and redundant code 2021-08-19 15:27:25 +05:30
MitulDavid
a3430ca2a9 feat: Image optimization 2021-08-02 18:23:26 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Joseph Marie Alba
62d81b7610
Python 3 issue with re
Python 3 interprets string literals as Unicode strings, and therefore \s is treated as an escaped Unicode character.

Declare RegEx pattern as a raw string instead by prepending r
2021-05-16 05:59:47 +08:00
KanchanChauhan
613b91735e
fix: Image shown as broken in comment if private 2020-08-21 17:58:37 +05:30
Himanshu
5b1938afdd feat(Comments): add images in comments (#8283)
* feat: add images in comments

* fix: use extract images
2019-09-02 23:28:05 +05:30
FinByz Tech Pvt. Ltd
245a8186af fix: Allowed guest to attach files to web forms (#7017)
Created the fix for the issue [#6774](https://github.com/frappe/frappe/issues/6774), in which guest can attach files in web forms like job application.
2019-03-06 22:48:11 +05:30
Aditya Hase
6b72faf44f style: Linting fixes (#6809)
* style: Remove unused imports

* style: Remove unused local variables
2019-01-23 16:39:55 +05:30
Charles-Henri Decultot
98abda32b4 [Enhancement] Event timeline (#6133)
* Events in timeline wip

* Events in timeline

* Permission issue + split buttons between Frappe and ERPNext

* Add string type check

* Codacy corrections

* Permission issue

* Test and feedback corrections

* Codacy corrections

* Tests and codacy corrections

* Codacy correction

* Py3 correction

* Travis correction

* Py3 corrections"

* Travis and codacy corrections

* Removed space

* Add check for the removal of new lines

* Codacy rollup watch missing semicolon
2018-10-02 10:12:55 +05:30
Rohit Waghchaure
c197ae6278 [Fix] Download report not working 2018-08-17 11:10:51 +05:30
Rushabh Mehta
db51e4441a fix(attach) for web forms 2018-08-04 21:51:49 +05:30
Ameya Shenoy
fc99d691d1 Fix python3 issue reading pdf (#5541)
File types other than plain text files weren't sent properly in email. The initial implementation of try except used to destroy the file object in the try statement, and hence we were getting a blank string in the except block. The fix involves reading the file object separately before trying to decode it.
2018-05-08 15:41:12 +05:30
Faris Ansari
da3e726fde
[fix] GCalendar Account test (#5400)
* [fix] GCalendar Account test

* [py3] fix email account test

* Decode plain text files
2018-04-07 22:38:12 +05:30
Nabin Hait
82f1058ad4 Merge branch 'master' into develop 2018-04-04 11:23:21 +05:30
Zarrar
edd089d4a1 append now_time to the filename incase of duplicate (#5313) 2018-04-02 18:22:12 +05:30
Zlash65
fae68f7d35 encode unicode objects 2018-03-26 14:59:41 +05:30
Achilles Rasquinha
6d8658decd fix content hash 2018-03-26 10:14:45 +05:30
Nabin Hait
3f3d9e52c8 Fixed merge conflict 2018-03-23 15:16:18 +05:30
Zarrar
577ce03fd8 [Hotfix] File upload fix (#5254)
* append hash if same filename found while uploading through socketio

* pass file size

* upload after filename change
2018-03-23 15:13:58 +05:30
Achilles Rasquinha
962f727283 save_file for bytes 2018-03-12 14:37:20 +05:30
Achilles Rasquinha
67132f775c bytes to string 2018-03-12 14:31:04 +05:30
Achilles Rasquinha
3a18f5d47f content bytes 2018-03-09 13:51:27 +05:30