Mercurial > p > roundup > code
annotate roundup/exceptions.py @ 5004:494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
In general outputting un-escaped HTML in a message to the user is an
unsafe operation, which is why error message are escaped by default. In
some cases though it is desirable for a detector to include HTML within
an error message. For these cases where HTML is required the RejectRaw
exception can be used within the detector.
| author | John Kristensen <john@jerrykan.com> |
|---|---|
| date | Sat, 10 Oct 2015 23:35:51 +1100 |
| parents | bbab97f8ffb2 |
| children | 32f95ec6bd8e |
| rev | line source |
|---|---|
| 4083 | 1 """Exceptions for use across all Roundup components. |
| 2 """ | |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 __docformat__ = 'restructuredtext' |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 |
| 4083 | 6 class LoginError(Exception): |
| 7 pass | |
| 8 | |
| 9 class Unauthorised(Exception): | |
| 10 pass | |
| 11 | |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 class Reject(Exception): |
| 4083 | 13 """An auditor may raise this exception when the current create or set |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 operation should be stopped. |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 It is up to the specific interface invoking the create or set to |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 handle this exception sanely. For example: |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 - mailgw will trap and ignore Reject for file attachments and messages |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 - cgi will trap and present the exception in a nice format |
| 4083 | 21 """ |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 pass |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 |
|
5004
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
24 |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
25 class RejectRaw(Reject): |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
26 """ |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
27 Performs the same function as Reject, except HTML in the message is not |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
28 escaped when displayed to the user. |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
29 """ |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
30 pass |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
31 |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
32 |
|
4066
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
33 class UsageError(ValueError): |
|
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
34 pass |
|
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
35 |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 # vim: set filetype=python ts=4 sw=4 et si |
