Merge branch 'invalid_utf8' into 'master'
Return proper error in case of invalid UTF-8 See merge request famedly/conduit!110
This commit is contained in:
		
						commit
						4732aa6782
					
				
					 3 changed files with 53 additions and 49 deletions
				
			
		|  | @ -157,15 +157,19 @@ pub async fn register_route( | ||||||
|             } |             } | ||||||
|         // Success!
 |         // Success!
 | ||||||
|         } else { |         } else { | ||||||
|             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |             if let Some(json) = body.json_body { | ||||||
|             db.uiaa.create( |                 uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|                 &UserId::parse_with_server_name("", db.globals.server_name()) |                 db.uiaa.create( | ||||||
|                     .expect("we know this is valid"), |                     &UserId::parse_with_server_name("", db.globals.server_name()) | ||||||
|                 "".into(), |                         .expect("we know this is valid"), | ||||||
|                 &uiaainfo, |                     "".into(), | ||||||
|                 &body.json_body.expect("body is json"), |                     &uiaainfo, | ||||||
|             )?; |                     &json, | ||||||
|             return Err(Error::Uiaa(uiaainfo)); |                 )?; | ||||||
|  |                 return Err(Error::Uiaa(uiaainfo)); | ||||||
|  |             } else { | ||||||
|  |                 return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -526,14 +530,14 @@ pub async fn change_password_route( | ||||||
|         } |         } | ||||||
|     // Success!
 |     // Success!
 | ||||||
|     } else { |     } else { | ||||||
|         uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |         if let Some(json) = body.json_body { | ||||||
|         db.uiaa.create( |             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|             &sender_user, |             db.uiaa | ||||||
|             &sender_device, |                 .create(&sender_user, &sender_device, &uiaainfo, &json)?; | ||||||
|             &uiaainfo, |             return Err(Error::Uiaa(uiaainfo)); | ||||||
|             &body.json_body.expect("body is json"), |         } else { | ||||||
|         )?; |             return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|         return Err(Error::Uiaa(uiaainfo)); |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     db.users |     db.users | ||||||
|  | @ -618,14 +622,14 @@ pub async fn deactivate_route( | ||||||
|         } |         } | ||||||
|     // Success!
 |     // Success!
 | ||||||
|     } else { |     } else { | ||||||
|         uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |         if let Some(json) = body.json_body { | ||||||
|         db.uiaa.create( |             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|             &sender_user, |             db.uiaa | ||||||
|             &sender_device, |                 .create(&sender_user, &sender_device, &uiaainfo, &json)?; | ||||||
|             &uiaainfo, |             return Err(Error::Uiaa(uiaainfo)); | ||||||
|             &body.json_body.expect("body is json"), |         } else { | ||||||
|         )?; |             return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|         return Err(Error::Uiaa(uiaainfo)); |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Leave all joined rooms and reject all invitations
 |     // Leave all joined rooms and reject all invitations
 | ||||||
|  |  | ||||||
|  | @ -116,14 +116,14 @@ pub async fn delete_device_route( | ||||||
|         } |         } | ||||||
|     // Success!
 |     // Success!
 | ||||||
|     } else { |     } else { | ||||||
|         uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |         if let Some(json) = body.json_body { | ||||||
|         db.uiaa.create( |             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|             &sender_user, |             db.uiaa | ||||||
|             &sender_device, |                 .create(&sender_user, &sender_device, &uiaainfo, &json)?; | ||||||
|             &uiaainfo, |             return Err(Error::Uiaa(uiaainfo)); | ||||||
|             &body.json_body.expect("body is json"), |         } else { | ||||||
|         )?; |             return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|         return Err(Error::Uiaa(uiaainfo)); |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     db.users.remove_device(&sender_user, &body.device_id)?; |     db.users.remove_device(&sender_user, &body.device_id)?; | ||||||
|  | @ -170,14 +170,14 @@ pub async fn delete_devices_route( | ||||||
|         } |         } | ||||||
|     // Success!
 |     // Success!
 | ||||||
|     } else { |     } else { | ||||||
|         uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |         if let Some(json) = body.json_body { | ||||||
|         db.uiaa.create( |             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|             &sender_user, |             db.uiaa | ||||||
|             &sender_device, |                 .create(&sender_user, &sender_device, &uiaainfo, &json)?; | ||||||
|             &uiaainfo, |             return Err(Error::Uiaa(uiaainfo)); | ||||||
|             &body.json_body.expect("body is json"), |         } else { | ||||||
|         )?; |             return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|         return Err(Error::Uiaa(uiaainfo)); |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for device_id in &body.devices { |     for device_id in &body.devices { | ||||||
|  |  | ||||||
|  | @ -145,14 +145,14 @@ pub async fn upload_signing_keys_route( | ||||||
|         } |         } | ||||||
|     // Success!
 |     // Success!
 | ||||||
|     } else { |     } else { | ||||||
|         uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); |         if let Some(json) = body.json_body { | ||||||
|         db.uiaa.create( |             uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); | ||||||
|             &sender_user, |             db.uiaa | ||||||
|             &sender_device, |                 .create(&sender_user, &sender_device, &uiaainfo, &json)?; | ||||||
|             &uiaainfo, |             return Err(Error::Uiaa(uiaainfo)); | ||||||
|             &body.json_body.expect("body is json"), |         } else { | ||||||
|         )?; |             return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); | ||||||
|         return Err(Error::Uiaa(uiaainfo)); |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if let Some(master_key) = &body.master_key { |     if let Some(master_key) = &body.master_key { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue