irelephant [he/him]@lemmy.dbzer0.com to Fediverse@lemmy.worldEnglish · 6 hours agoFun fact: you can't upload this image on piefed.sociallemmy.dbzer0.comimagemessage-square32fedilinkarrow-up134arrow-down13file-text
arrow-up131arrow-down1imageFun fact: you can't upload this image on piefed.sociallemmy.dbzer0.comirelephant [he/him]@lemmy.dbzer0.com to Fediverse@lemmy.worldEnglish · 6 hours agomessage-square32fedilinkfile-text
https://codeberg.org/rimu/pyfedi/src/commit/6405e51dab23f43eaea18d0ee4d9e7a773a3fd31/app/community/forms.py#L335 deliberately misleading error message.
minus-squareirelephant [he/him]@lemmy.dbzer0.comOPlinkfedilinkEnglisharrow-up8·3 hours agoThe snippet that does this is: if site.enable_chan_image_filter: # Do not allow fascist meme content try: if '.avif' in uploaded_file.filename: import pillow_avif # NOQA image_text = pytesseract.image_to_string(Image.open(BytesIO(uploaded_file.read())).convert('L')) except FileNotFoundError: image_text = '' except UnidentifiedImageError: image_text = '' if 'Anonymous' in image_text and ( 'No.' in image_text or ' N0' in image_text): # chan posts usually contain the text 'Anonymous' and ' No.12345' self.image_file.errors.append( "This image is an invalid file type.") # deliberately misleading error message current_user.reputation -= 1 db.session.commit() return False (Link in the post body)
The snippet that does this is:
if site.enable_chan_image_filter: # Do not allow fascist meme content try: if '.avif' in uploaded_file.filename: import pillow_avif # NOQA image_text = pytesseract.image_to_string(Image.open(BytesIO(uploaded_file.read())).convert('L')) except FileNotFoundError: image_text = '' except UnidentifiedImageError: image_text = '' if 'Anonymous' in image_text and ( 'No.' in image_text or ' N0' in image_text): # chan posts usually contain the text 'Anonymous' and ' No.12345' self.image_file.errors.append( "This image is an invalid file type.") # deliberately misleading error message current_user.reputation -= 1 db.session.commit() return False(Link in the post body)