ti2-tourplan 1.0.42 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -142,12 +142,14 @@ class Plugin {
142
142
  if (!replyObj) {
143
143
  // in case of error /xmlproxy, fallback to call tourplan directly
144
144
  // and then use pyfilematch xml2json to parse the xml
145
- const reply = R.path(['data'], await axios({
145
+ const axiospayload = {
146
146
  method: 'post',
147
147
  url: endpoint,
148
148
  data,
149
149
  headers: getHeaders({ length: data.length }),
150
- }));
150
+ };
151
+ // console.log(axiospayload)
152
+ const reply = R.path(['data'], await axios(axiospayload));
151
153
  if (this.xmlProxyUrl) {
152
154
  try {
153
155
  // using raw axios to avoid logging the large xml request
@@ -213,15 +215,15 @@ class Plugin {
213
215
  if (passengers && passengers.length && !noPaxList) {
214
216
  RoomConfig.PaxList = passengers.map(p => {
215
217
  const PaxDetails = {
216
- Forename: p.firstName,
217
- Surname: p.lastName,
218
+ Forename: this.escapeInvalidXmlChars(p.firstName),
219
+ Surname: this.escapeInvalidXmlChars(p.lastName),
218
220
  PaxType: {
219
221
  Adult: 'A',
220
222
  Child: 'C',
221
223
  Infant: 'I',
222
224
  }[p.passengerType] || 'A',
223
225
  };
224
- if (p.salutation) PaxDetails.Title = p.salutation;
226
+ if (p.salutation) PaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
225
227
  if (p.dob) PaxDetails.DateOfBirth = p.dob;
226
228
  if (!R.isNil(p.age) && !isNaN(p.age)) {
227
229
  if (!(p.passengerType === 'Adult' && p.age === 0)) {
@@ -237,7 +239,10 @@ class Plugin {
237
239
  });
238
240
  this.escapeInvalidXmlChars = str => {
239
241
  if (!str) return '';
240
- return str.replace(/[^\x00-\x7F]+/g, '')
242
+ const convertAccentedChars = s => {
243
+ return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
244
+ }
245
+ return convertAccentedChars(str)
241
246
  .replace(/’/g, "'")
242
247
  .replace(/‘/g, "'")
243
248
  .replace(/“/g, '"')
@@ -694,7 +699,7 @@ class Plugin {
694
699
  ${doInfo.flightDetails ? `Flight: ${doInfo.flightDetails || 'NA'},` : ''}
695
700
  `),
696
701
  } : {}),
697
- Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 240),
702
+ Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 220),
698
703
  Opt: optionId,
699
704
  DateFrom: startDate,
700
705
  RateId: 'Default',
@@ -773,10 +778,10 @@ class Plugin {
773
778
  });
774
779
  let searchCriterias = [];
775
780
  if (bookingId) {
776
- searchCriterias = ['BookingId', 'Ref', 'AgentRef'].map(key => ({ [key]: bookingId }));
781
+ searchCriterias = ['BookingId', 'Ref', 'AgentRef'].map(key => ({ [key]: this.escapeInvalidXmlChars(bookingId) }));
777
782
  }
778
783
  if (name) {
779
- searchCriterias.push({ NameContains: name });
784
+ searchCriterias.push({ NameContains: this.escapeInvalidXmlChars(name) });
780
785
  }
781
786
  const allSearches = searchCriterias.length
782
787
  ? searchCriterias.map(async keyObj => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {