Return original text that fails to decode
This commit is contained in:
		
							parent
							
								
									d66794c305
								
							
						
					
					
						commit
						a4ccaae4ae
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		|  | @ -10,19 +10,16 @@ from nntp.tiny.db import DatabaseTable | ||||||
| def decode(text: str): | def decode(text: str): | ||||||
|     decoded = decode_header(text)[0] |     decoded = decode_header(text)[0] | ||||||
| 
 | 
 | ||||||
|     if decoded[1] is None: |     if decoded[0] == b'': | ||||||
|         if decoded[0] == b'': |         return '' | ||||||
|             return '' |  | ||||||
| 
 | 
 | ||||||
|         return str(decoded[0]) |     if decoded[1] is None: | ||||||
|  |         return text | ||||||
| 
 | 
 | ||||||
|     try: |     try: | ||||||
|         return str(decoded[0], decoded[1]) |         return str(decoded[0], decoded[1]) | ||||||
|     except: |     except: | ||||||
|         if decoded[0] == b'': |         return text | ||||||
|             return '' |  | ||||||
| 
 |  | ||||||
|         return str(decoded[0]) |  | ||||||
| 
 | 
 | ||||||
| def each_line(text: str): | def each_line(text: str): | ||||||
|     start = 0 |     start = 0 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue