예제 #1
0
 public void StartAndEndJsonPaddingSuccessTest()
 {
     settings.JsonPCallback = "functionName";
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     ODataJsonWriterUtils.EndJsonPaddingIfRequired(this.jsonWriter, settings);
     stringWriter.GetStringBuilder().ToString().Should().Be("functionName()");
 }
예제 #2
0
        /// <summary>
        /// Writes the start of the entire JSON payload.
        /// </summary>
        /// <param name="disableResponseWrapper">When set to true the "d" response wrapper won't be written even in responses</param>
        internal void WritePayloadStart(bool disableResponseWrapper)
        {
            DebugUtils.CheckNoExternalCallers();

            ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.JsonWriter, this.MessageWriterSettings);

            if (this.WritingResponse && !disableResponseWrapper)
            {
                // If we're writing a response payload the entire JSON should be wrapped in { "d":  } to guard against XSS attacks
                // it makes the payload a valid JSON but invalid JScript statement.
                this.JsonWriter.StartObjectScope();
                this.JsonWriter.WriteDataWrapper();
            }
        }
 internal void WritePayloadStart()
 {
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.JsonWriter, this.MessageWriterSettings);
 }
예제 #4
0
 public void StartJsonPaddingIfRequiredWillDoNothingIfEmptyFunctionName()
 {
     settings.JsonPCallback = "";
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     stringWriter.GetStringBuilder().ToString().Should().BeEmpty();
 }
예제 #5
0
 public void StartJsonPaddingIfRequiredWillDoNothingIfNullFunctionName()
 {
     settings.JsonPCallback = null;
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     Assert.Empty(stringWriter.GetStringBuilder().ToString());
 }
예제 #6
0
 internal void WritePayloadStart()
 {
     DebugUtils.CheckNoExternalCallers();
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.JsonWriter, this.MessageWriterSettings);
 }