@@ -122,6 +122,24 @@ public async Task RejectsOversizedPayloadsThroughProtocolValidation()
122122 Assert . Equal ( "invalid_payload" , result . Reason ) ;
123123 }
124124
125+ [ Fact ]
126+ public async Task AcceptsApostropheTextPayloadWithAndroidCompatibleAuthProof ( )
127+ {
128+ CommandAuthValidator validator = new ( CreateStore ( ) , ( ) => Now ) ;
129+
130+ AuthValidationResult result = await validator . ValidateAsync ( CreateTextCommand ( "apostrophe-1" , "'" , "W0OLnbhllDOCd0Gf_00WLpHRvfidYjHeY69nbcmTFYA" ) ) ;
131+
132+ Assert . True ( result . Ok , result . Reason ) ;
133+ }
134+
135+ [ Fact ]
136+ public void EscapesTextPayloadsLikeAndroidProtocolAuth ( )
137+ {
138+ Assert . Equal ( "W0OLnbhllDOCd0Gf_00WLpHRvfidYjHeY69nbcmTFYA" , CommandAuth . CreateCommandAuthProof ( CreateTextCommand ( "apostrophe-1" , "'" ) , Token ) ) ;
139+ Assert . Equal ( "UfVuw9DJjDofw7UeXBZcIFAu5V2YSkEfJ5p0h8_z2UY" , CommandAuth . CreateCommandAuthProof ( CreateTextCommand ( "backslash-1" , "\\ " ) , Token ) ) ;
140+ Assert . Equal ( "syal1vfAvjac7RNhm8S_2fj-Edk5k1KkGeIMc7eBelw" , CommandAuth . CreateCommandAuthProof ( CreateTextCommand ( "html-1" , "<>&'" ) , Token ) ) ;
141+ }
142+
125143 [ Fact ]
126144 public void MatchesKnownTypeScriptAuthFixtures ( )
127145 {
@@ -165,6 +183,20 @@ private static JsonElement CreateMouseMoveCommand(Dictionary<string, object?>? o
165183 } , overrides ) ;
166184 }
167185
186+ private static JsonElement CreateTextCommand ( string id , string text , string ? authOverride = null )
187+ {
188+ return CreateSignedCommand ( new Dictionary < string , object ? >
189+ {
190+ [ "version" ] = ProtocolConstants . ProtocolVersion ,
191+ [ "id" ] = id ,
192+ [ "deviceId" ] = "android-1" ,
193+ [ "timestamp" ] = Now ,
194+ [ "type" ] = "keyboard.typeText" ,
195+ [ "payload" ] = new Dictionary < string , object ? > { [ "text" ] = text } ,
196+ [ "auth" ] = authOverride ?? ""
197+ } , authOverride is null ? null : new Dictionary < string , object ? > { [ "auth" ] = authOverride } ) ;
198+ }
199+
168200 private static JsonElement CreateSignedCommand ( Dictionary < string , object ? > command , Dictionary < string , object ? > ? overrides )
169201 {
170202 if ( overrides is not null )
0 commit comments