Fix invalid blurhash handling in Create activity (#16583)
This commit is contained in:
		
							parent
							
								
									496945f4c4
								
							
						
					
					
						commit
						15a56e3717
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
					@ -446,10 +446,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def supported_blurhash?(blurhash)
 | 
					  def supported_blurhash?(blurhash)
 | 
				
			||||||
    components = blurhash.blank? ? nil : Blurhash.components(blurhash)
 | 
					    components = blurhash.blank? || !blurhash_valid_chars?(blurhash) ? nil : Blurhash.components(blurhash)
 | 
				
			||||||
    components.present? && components.none? { |comp| comp > 5 }
 | 
					    components.present? && components.none? { |comp| comp > 5 }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def blurhash_valid_chars?(blurhash)
 | 
				
			||||||
 | 
					    /^[\w#$%*+-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def skip_download?
 | 
					  def skip_download?
 | 
				
			||||||
    return @skip_download if defined?(@skip_download)
 | 
					    return @skip_download if defined?(@skip_download)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue