gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
282 stars 73 forks source link

string of search filter need to be xml encoded, otherwise it will cause SoapFault #97

Open kingcpro opened 8 years ago

kingcpro commented 8 years ago

var msgid_filter = new ews.SearchFilter.IsEqualTo(ews.EmailMessageSchema.InternetMessageId, "<1265C662-5918-4F05-9A52-554796A681AB@example.com>");

Above filter will cause below error:

Element: Violation - Please report example of this operation to ews-javascript-api repo to improve SoapFault parsing
errors exist
SoapFaultDetails {
  faultCode: 'a:ErrorSchemaValidation',
  faultString: 
   { 'xml:lang': 'en-US',
     faultstring: 'The request failed schema validation: \'<\', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 709.' },
  faultActor: null,
  responseCode: 355,
  message: 'The request failed schema validation.',
  errorCode: 0,
  exceptionType: null,
  lineNumber: 1,
  positionWithinLine: 709,
  errorDetails: 
   DictionaryWithStringKey {
     keys: [ 'Violation' ],
     keysToObjs: { Violation: 'Violation' },
     objects: { Violation: '\'<\', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 709.' },
     keyPicker: [Function] } }

After changed to xml encoded string, it works. var msgid_filter = new ews.SearchFilter.IsEqualTo(ews.EmailMessageSchema.InternetMessageId, "&lt;1265C662-5918-4F05-9A52-554796A681AB@example.com&gt;");

gautamsi commented 8 years ago

I looked into official code (snapshot I am porting from), looks like it is expected to be normalized string.

I will look into this later around 1.1 or 1.2 update