Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes on some SOAP 1.2 requests when using GetBufferedInputStream #1811

Merged
merged 6 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,18 @@ private static bool IsSoap12Action(NameValueCollection headers)

internal static string GetSoap12ActionFromInputStream(Stream stream)
{
StreamReader streamReader = null;
try
{
streamReader = new StreamReader(stream);
var settings = new XmlReaderSettings
{
IgnoreProcessingInstructions = true,
IgnoreComments = true,
IgnoreWhitespace = true
};

using var reader = XmlReader.Create(stream, settings);
using var reader = XmlReader.Create(streamReader, settings);
reader.MoveToContent();
if (reader.LocalName != "Envelope")
return null;
Expand All @@ -116,6 +118,10 @@ internal static string GetSoap12ActionFromInputStream(Stream stream)
//If that's the case we don't need to care about them here. They will flow somewhere else.
return null;
}
finally
{
streamReader?.ReadToEnd();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ public SoapRequestTests(ITestOutputHelper xUnitOutputHelper)
/// does not cause an exception to be thrown when the framework deserializes the input stream
/// to parse the parameters for the web method.
/// </summary>
[AspNetFullFrameworkFact]
public async Task Name_Should_Should_Not_Throw_Exception_When_Asmx_Soap12_Request()
[AspNetFullFrameworkTheory]
[InlineData(false)]
[InlineData(true)]
public async Task Name_Should_Should_Not_Throw_Exception_When_Asmx_Soap12_Request(bool useLargePayload)
{
var pathData = SampleAppUrlPaths.CallSoapServiceProtocolV12;
var action = "Input";

var input = @"This is the input";
var input = useLargePayload ? string.Join("", Enumerable.Repeat("This is a large input. ", 500)) : "This is the input";

var request = new HttpRequestMessage(HttpMethod.Post, pathData.Uri)
{
Content = new StringContent($@"<?xml version=""1.0"" encoding=""utf-8""?>
Expand Down