Skip to content

Commit 4d6aa37

Browse files
authored
fix: RawBone looses its value when invalid (#1595)
When something entered is wrong, it should not be returned the empty value.
1 parent 93f14ca commit 4d6aa37

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/viur/core/bones/raw.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
class RawBone(BaseBone):
88
"""
9-
Stores its data without applying any pre/post-processing or filtering. Can be used to store
10-
non-html content.
11-
Use the dot-notation like "raw.markdown" or similar to describe subsequent types.
9+
Stores its data without applying any pre/post-processing or filtering.
10+
Can be used to store any textual content.
11+
12+
Use the dot-notation like "raw.code.markdown" or similar to describe subsequent types.
13+
This can also be achieved by adding `type_suffix="code.markdown"` to the RawBone's instantiation.
1214
1315
..Warning: Using this bone will lead to security vulnerabilities like reflected XSS unless the
1416
data is either otherwise validated/stripped or from a trusted source! Don't use this unless
@@ -17,9 +19,9 @@ class RawBone(BaseBone):
1719
type = "raw"
1820

1921
def singleValueFromClient(self, value, skel, bone_name, client_data):
20-
err = self.isInvalid(value)
21-
if err:
22-
return self.getEmptyValue(), [ReadFromClientError(ReadFromClientErrorSeverity.Invalid, err)]
22+
if err := self.isInvalid(value):
23+
return value, [ReadFromClientError(ReadFromClientErrorSeverity.Invalid, err)]
24+
2325
return value, None
2426

2527
def getSearchTags(self, skel: "SkeletonInstance", name: str) -> set[str]:

0 commit comments

Comments
 (0)