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