Commit graph

361 commits

Author SHA1 Message Date
Kaushal Shriwas
8ade4ce27d fix: preserve numeric-shaped docnames without losing JSON parsing of scalars 2026-04-30 15:28:55 +05:30
Kaushal Shriwas
470964015e fix: also parse JSON-encoded scalar strings in get_safe_filters 2026-04-30 15:10:13 +05:30
Kaushal Shriwas
46fd36d542 refactor: simplify get_safe_filters guard for readability 2026-04-30 13:31:19 +05:30
Kaushal Shriwas
ff83bb1473 fix: preserve docnames matching scientific notation in get_safe_filters 2026-04-30 13:15:04 +05:30
Raffael Meyer
bedb08485e
fix: use secrets for random string generation (#38338) 2026-03-30 19:08:16 +02:00
Angel98518
0c59f49ce3
fix: remove redundant isinstance check in encode_dict (#35932)
* fix: remove redundant isinstance check in encode_dict

The encode_dict function was checking isinstance(d[key], str) twice,
which is redundant. Removed the duplicate check to clean up the code.

This is a simple code quality improvement that removes unnecessary
redundancy in the type checking logic.

* fix: correct decode_dict to check for bytes instead of always-false condition

The decode_dict function had a logic error:
'isinstance(d[key], str) and not isinstance(d[key], str)' is always False.
It should check for bytes instead, since decode() is called on bytes objects.

This fixes the decode_dict function to properly decode bytes to strings.

* fix: remove redundant isinstance check in encode_dict

---------

Co-authored-by: Daniel Miner <daniel@gittensor.miner>
2026-01-30 04:09:58 +00:00
Saqib Ansari
61679295aa chore: move common utility functions to frappe.utils 2026-01-04 14:20:40 +05:30
Akhil Narang
e859b1d312
fix: disable UP040, revert some instances to TypeAlias
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-23 13:12:04 +05:30
Akhil Narang
90a40dbfe0
fix: ruff manual fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
f7feeea0a0
fix: ruff "unsafe" fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
8723a2b6ee
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Hardik Zinzuvadiya
b5f22227ab feat(utils): replace custom email parsing with RFC-compliant validation (fixes #27337)
Replaced the old comma-split based email parsing with `email.utils.getaddresses`
to correctly handle RFC 5322 formatted addresses, including display names
containing commas (e.g. `"Last, First" <email@example.com>`).

The previous implementation incorrectly split on commas and treated parts of
display names as standalone emails, causing valid inputs to fail validation and
breaking Communication creation (e.g. `"Gritton, Howard" <hgrit@example.com>`).

The new validator:
- correctly parses display names with commas
- handles multiple addresses and multiline input
- skips undisclosed recipients
- preserves existing EMAIL_MATCH_PATTERN validation
- returns only the email addresses (same as before)

Added additional test cases covering RFC-compliant inputs and empty-addr scenarios.
Fixes frappe/frappe#27337.
2025-12-07 06:38:12 +00:00
Akhil Narang
0ea49a8f1e
fix: make sure limit is an integer
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-11-19 21:15:57 +05:30
Akhil Narang
6ca4d4d167
refactor(treewide): ruff format
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-09-26 13:16:43 +05:30
Hussain Nagaria
6644159440
fix: gracefully handle missing from header in email (#33996) 2025-09-16 05:36:26 +00:00
barredterra
b1c7821911 feat: validate IBAN in backend 2025-08-29 15:21:56 +02:00
Vehbi Unal
c6a2e6595a fix(utils): convert phone numbers passed into validate_phone_number to strings 2025-07-24 13:02:55 +00:00
Ankush Menat
afb720e003
refactor: move stuff away from init.py (#33283)
* chore: Drop unused imports

* refactor: split translation utils from init.py

* refactor: move sendmail from init.py

* refactor: move prints to attach_print
2025-07-11 07:18:16 +00:00
Sagar Vora
2e5c8bea03 feat: frappe.utils.orjson_dumps 2025-06-26 17:37:51 +05:30
Sagar Vora
cda7699187 perf: use orjson in utils 2025-06-26 17:37:51 +05:30
Sagar Vora
b3e1eda4c8
feat: global frappe.in_test flag (#32960)
* feat: global `frappe.in_test` flag

* feat: helper utility to toggle `frappe.in_test`

* fix: use `toggle_test_mode` util

* fix: use `frappe.in_test`

* chore: add comment explaining global `in_test`

* chore: ignore commit replacing flag usage

* test: temporarily disable `frappe.in_test`

this worked earlier because flag was set in werkzeug.local which was separate for API test client

* test: add comment explaining change
2025-06-17 19:19:31 +05:30
Ankush Menat
a278ff2356 chore: remove invalid return type 2025-06-05 21:38:14 +05:30
Ankush Menat
051aba3049
fix(DX): Fix type annotations for custom cached_property (#32785)
+ Avoid custom implementation on newer python versions entirely.
2025-06-04 16:37:35 +00:00
rohitwaghchaure
5c6b2b5bec
refactor: track completed app setup wizards and re-run the setup wizard upon new app installation. (#32640) 2025-06-03 12:36:22 +05:30
Ankush Menat
85f8ccadf7
Revert "feat: support reraising with error cause" (#32523)
This reverts commit 153d7cb7a3.
2025-05-15 17:35:18 +05:30
Sagar Vora
ac39749929
Merge pull request #32082 from sagarvora/cached-prop
feat: use `cached_property` without locks on all supported Python versions
2025-04-11 13:49:49 +05:30
Sagar Vora
7421ffa79a feat: use cached_property without locks on all supported Python versions 2025-04-11 13:21:27 +05:30
Henning Wendtland
b59a94a523
fix: improve url validation (#32052) 2025-04-11 11:51:08 +05:30
Sagar Vora
bd844579d2 refactor: trim frappe.__init__ 2025-04-06 10:30:23 +05:30
Ankush Menat
ae4e2ede1a refactor: move init.py utils to utils/* 2025-03-10 21:01:14 +05:30
Ankush Menat
cde1662791 perf: use client side cache for assets.json
Single shared key, worth the costs.
2025-01-14 13:57:41 +05:30
David Arnold
2f559e0fa9
chore: make the type clear (#28524) 2024-11-19 22:40:26 +00:00
David Arnold
8d6f8bce01
chore(typing): add some more typing to frappe.__init__ (#28215) 2024-10-21 11:30:11 +00:00
David Arnold
8cfeb156df
devx: add deprecation dumpster (#27887)
* feat: Add deprecation_dumpster.py file

* docs: add jovial and jocose docstring for frappe/deprecation_dumpster.py

* refactor: fill the dumpster with its own kind

* refactor: move to the deprecation dumpster

* chore: color coding class

* fix: only check import error when import errors
2024-10-08 18:56:10 +02:00
David
0aa652a565
fix: back compat 2024-06-24 10:16:51 +02:00
David
153d7cb7a3
feat: support reraising with error cause 2024-06-01 14:57:07 +02:00
Akhil Narang
45ffcf606e
Merge pull request #26462 from akhilnarang/tar-ignore-file-changed-as-we-read-it
feat: ignore `tar: file changed as we read it` during backups
2024-05-21 11:46:05 +05:30
Ankush Menat
025727674f
fix: scheduled type syncing (#26490)
- Scheduled Job sync when type was changed from scheduled to some other
  type didn't work.
- It updates on every save with message, bad DX IMO (can't save script
  and edit without dismissing)
- This was because of complex walrus which was triggering rest of code
  even when nothing changed. Maybe walrus opponents were onto something.
- `Truthy` couples two different operations and hence makes code
  complicated. In most cases where these checks are required it's not
  performance critical, we can do 1 more function call to avoid this
  coupling of change + actual value.
2024-05-20 13:43:20 +00:00
Akhil Narang
e3e6834b5d
fix: add errors=replace to decode() call
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-05-17 15:03:32 +05:30
Akhil Narang
803b45b9fa
feat: ignore tar: file changed as we read it during backups
This seems to occur when new files are being created as we're archiving
the files on a site. Doesn't make sense to fail the entire backup
because of that.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-05-17 11:39:41 +05:30
gavin
665a18b063
fix: Implement Truthy.__eq __
Implement equality check, compare with True rather than self for a Truthy instance

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2024-05-13 14:17:40 +02:00
Gavin D'souza
36c80b77a4
fix: Set value default True for Truthy cls 2024-05-07 17:43:19 +02:00
Gavin D'souza
ffbf7fb9d1
fix!: Document.has_value_changed returns Truthy or False
- Return changed value to avoid re-accessing previous object & it's
   attribute
 - Wrap returned value as Truthy to avoid breaking change in API
2024-05-07 17:29:48 +02:00
Ankush Menat
d40b2a2517 fix(UX): help links and relative URLs
also closes https://github.com/frappe/frappe/issues/23020
2024-04-22 12:10:28 +05:30
Akhil Narang
1847e9cae8
fix: pass function as lambda
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Suraj Shetty
ec4261bd77 fix: Do not check for email validation on empty string 2024-03-02 21:20:51 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
afef4b8f30
fix: add short timeout to gravatar (#24414)
closes https://github.com/frappe/frappe/issues/24377
2024-01-17 09:08:00 +00:00