Skip to content

Commit 1745973

Browse files
committed
TROPO-12171
deal with the backslash in header's value
1 parent 93b1069 commit 1745973

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

TropoCSharp/TropoJSON.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public static void RenderJSON(this Tropo tropo, HttpResponse response)
1515
tropo.Voice = null;
1616
JsonSerializerSettings settings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore };
1717
response.AddHeader("WebAPI-Lang-Ver", "CSharp V15.9.0 SNAPSHOT");
18-
response.Write(JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}"));
18+
string sorig = JsonConvert.SerializeObject(tropo, Formatting.None, settings);
19+
string s = sorig.Replace("\\\"", "\"").Replace("\\\\", "\\").Replace("\"{", "{").Replace("}\"", "}");
20+
response.Write(s);
1921

2022
}
2123
}

TropoClassesTests/TropoClassesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ private string renderJSONToText(Tropo tropo)
516516
tropo.Language = null;
517517
tropo.Voice = null;
518518
JsonSerializerSettings settings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore };
519-
return JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}");
519+
return JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\\"", "\"").Replace("\\\\", "\\").Replace("\"{", "{").Replace("}\"", "}");
520520
}
521521

522522
}

TropoSample/TROPO12171.aspx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TROPO12171.aspx.cs" Inherits="TropoSample.TROPO12171" %>
2+

TropoSample/TROPO12171.aspx.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web.UI;
4+
using TropoCSharp.Structs;
5+
using TropoCSharp.Tropo;
6+
7+
namespace TropoSample
8+
{
9+
/// <summary>
10+
/// A simple example demonstrating how to use the Ask method.
11+
/// </summary>
12+
public partial class TROPO12171 : Page
13+
{
14+
public void Page_Load(object sender, EventArgs args)
15+
{
16+
// Create a new instance of the Tropo object.
17+
Tropo tropo = new Tropo();
18+
19+
Say say1 = new Say("test remote party id 3");
20+
21+
IDictionary<string, string> headers = new Dictionary<String, String>();
22+
//headers.Add("P-Header", "TROPO12171value goes here");
23+
headers.Add("Remote-Party-ID", "\"John Doe\"<sip:jdoe@foo.com>TROPO12171ab;party=calling;id-type=subscriber;privacy=full;screen=yes");
24+
//headers.Add("Remote-Party-ID", "\\yigegang3");
25+
26+
//Answer answer = new Answer();
27+
//answer.Headers = headers;
28+
29+
tropo.Answer(headers);
30+
tropo.Say(say1);
31+
tropo.RenderJSON(Response);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)