Ejemplo n.º 1
0
 public void StartAndEndJsonPaddingSuccessTest()
 {
     settings.JsonPCallback = "functionName";
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     ODataJsonWriterUtils.EndJsonPaddingIfRequired(this.jsonWriter, settings);
     stringWriter.GetStringBuilder().ToString().Should().Be("functionName()");
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 public void StartJsonPaddingIfRequiredWillDoNothingIfEmptyFunctionName()
 {
     settings.JsonPCallback = "";
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     stringWriter.GetStringBuilder().ToString().Should().BeEmpty();
 }
Ejemplo n.º 5
0
 public void StartJsonPaddingIfRequiredWillDoNothingIfNullFunctionName()
 {
     settings.JsonPCallback = null;
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.jsonWriter, settings);
     Assert.Empty(stringWriter.GetStringBuilder().ToString());
 }
Ejemplo n.º 6
0
 internal void WritePayloadStart()
 {
     DebugUtils.CheckNoExternalCallers();
     ODataJsonWriterUtils.StartJsonPaddingIfRequired(this.JsonWriter, this.MessageWriterSettings);
 }