@@ -225,17 +225,33 @@ void EventPipeProvider::AddEvent(EventPipeEvent &event)
225
225
// of pairs of null terminated strings. The first member of the pair is
226
226
// the key and the second is the value.
227
227
// To convert to this format we need to convert all '=' and ';'
228
- // characters to '\0'.
228
+ // characters to '\0', except when in a quoted string .
229
229
SString dstBuffer;
230
230
SString (pFilterData).ConvertToUTF8 (dstBuffer);
231
231
232
232
const COUNT_T BUFFER_SIZE = dstBuffer.GetCount () + 1 ;
233
233
buffer.AllocThrows (BUFFER_SIZE);
234
+ BOOL isQuotedValue = false ;
235
+ COUNT_T j = 0 ;
234
236
for (COUNT_T i = 0 ; i < BUFFER_SIZE; ++i)
235
- buffer[i] = (dstBuffer[i] == ' =' || dstBuffer[i] == ' ;' ) ? ' \0 ' : dstBuffer[i];
237
+ {
238
+ // if a value is a quoted string, leave the quotes out from the destination
239
+ // and don't replace `=` or `;` characters until leaving the quoted section
240
+ // e.g., key="a;value=";foo=bar --> { key\0a;value=\0foo\0bar\0 }
241
+ if (dstBuffer[i] == ' "' )
242
+ {
243
+ isQuotedValue = !isQuotedValue;
244
+ continue ;
245
+ }
246
+ buffer[j++] = ((dstBuffer[i] == ' =' || dstBuffer[i] == ' ;' ) && !isQuotedValue) ? ' \0 ' : dstBuffer[i];
247
+ }
248
+
249
+ // In case we skipped over quotes in the filter string, shrink the buffer size accordingly
250
+ if (j < dstBuffer.GetCount ())
251
+ buffer.Shrink (j + 1 );
236
252
237
253
eventFilterDescriptor.Ptr = reinterpret_cast <ULONGLONG>(buffer.Ptr ());
238
- eventFilterDescriptor.Size = static_cast <ULONG>(BUFFER_SIZE );
254
+ eventFilterDescriptor.Size = static_cast <ULONG>(buffer. Size () );
239
255
eventFilterDescriptor.Type = 0 ; // EventProvider.cs: `internal enum ControllerCommand.Update`
240
256
isEventFilterDescriptorInitialized = true ;
241
257
}
0 commit comments