mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Fix several issues with char/paste event validation
- Fix isValidClipboard always returning true.
 - Fix characters >=128 being rejected. We changed the signature from a
   byte to an int in 0f123b5efd, but
   didn't update all call sites.
   Valhalla cannot come soon enough. I would love to be able to have
   (cheap) wrapper classes for some of these types.
See Zeus-guy's comments in #860.
			
			
This commit is contained in:
		| @@ -74,7 +74,7 @@ public class ServerInputState<T extends AbstractContainerMenu & ComputerMenu> im | ||||
|     } | ||||
| 
 | ||||
|     private static boolean isValidClipboard(ByteBuffer buffer) { | ||||
|         for (int i = buffer.remaining(), max = buffer.limit(); i < max; i++) { | ||||
|         for (int i = buffer.position(), max = buffer.limit(); i < max; i++) { | ||||
|             if (!StringUtil.isTypableChar(buffer.get(i))) return false; | ||||
|         } | ||||
|         return true; | ||||
|   | ||||
| @@ -70,6 +70,17 @@ public final class StringUtil { | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Check if a character is capable of being input and passed to a {@linkplain ComputerEvents#charTyped(ComputerEvents.Receiver, byte) | ||||
|      * "char" event}. | ||||
|      * | ||||
|      * @param chr The character to check. | ||||
|      * @return Whether this character can be typed. | ||||
|      */ | ||||
|     public static boolean isTypableChar(byte chr) { | ||||
|         return isTypableChar(chr & 0xFF); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Check if a character is capable of being input and passed to a {@linkplain ComputerEvents#charTyped(ComputerEvents.Receiver, byte) | ||||
|      * "char" event}. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates