File tree Expand file tree Collapse file tree 2 files changed +17
-18
lines changed
catalyst-signed-doc-macro/src/rules
signed_doc/src/validator/rules Expand file tree Collapse file tree 2 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ pub(crate) fn catalyst_signed_documents_rules_impl() -> anyhow::Result<TokenStre
2222 id: crate :: validator:: rules:: IdRule ,
2323 ver: crate :: validator:: rules:: VerRule ,
2424 content_type: crate :: validator:: rules:: ContentTypeRule :: NotSpecified ,
25- content_encoding: crate :: validator:: rules:: ContentEncodingRule {
25+ content_encoding: crate :: validator:: rules:: ContentEncodingRule :: Specified {
2626 exp: ContentEncoding :: Brotli ,
2727 optional: false ,
2828 } ,
Original file line number Diff line number Diff line change @@ -47,24 +47,23 @@ impl ContentTypeRule {
4747 ) ;
4848 return Ok ( false ) ;
4949 }
50+ let Ok ( content) = doc. decoded_content ( ) else {
51+ doc. report ( ) . functional_validation (
52+ "Invalid Document content, cannot get decoded bytes" ,
53+ "Cannot get a document content during the content type field validation" ,
54+ ) ;
55+ return Ok ( false ) ;
56+ } ;
57+ if self . validate ( & content) . is_err ( ) {
58+ doc. report ( ) . invalid_value (
59+ "payload" ,
60+ & hex:: encode ( content) ,
61+ & format ! ( "Invalid Document content, should {content_type} encodable" ) ,
62+ "Invalid Document content" ,
63+ ) ;
64+ return Ok ( false ) ;
65+ }
5066 }
51- let Ok ( content) = doc. decoded_content ( ) else {
52- doc. report ( ) . functional_validation (
53- "Invalid Document content, cannot get decoded bytes" ,
54- "Cannot get a document content during the content type field validation" ,
55- ) ;
56- return Ok ( false ) ;
57- } ;
58- if self . validate ( & content) . is_err ( ) {
59- doc. report ( ) . invalid_value (
60- "payload" ,
61- & hex:: encode ( content) ,
62- & format ! ( "Invalid Document content, should {content_type} encodable" ) ,
63- "Invalid Document content" ,
64- ) ;
65- return Ok ( false ) ;
66- }
67-
6867 Ok ( true )
6968 }
7069
You can’t perform that action at this time.
0 commit comments