-
Notifications
You must be signed in to change notification settings - Fork 280
Bugfix #1124 When CSDL filter and http resource supplied for HIDI input, it fails because ApplyFilter expects a local file but not a URL address #1125
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,7 +98,7 @@ CancellationToken cancellationToken | |||||||||||||||||||||||
| if (!string.IsNullOrEmpty(csdlFilter)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| XslCompiledTransform transform = GetFilterTransform(); | ||||||||||||||||||||||||
| stream = ApplyFilter(csdl, csdlFilter, transform); | ||||||||||||||||||||||||
| stream = csdl.StartsWith("http") ? ApplyFilter(stream, csdlFilter, transform) : ApplyFilter(csdl, csdlFilter, transform); | ||||||||||||||||||||||||
| stream.Position = 0; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -235,20 +235,32 @@ private static XslCompiledTransform GetFilterTransform() | |||||||||||||||||||||||
| return transform; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslCompiledTransform transform) | ||||||||||||||||||||||||
| private static Stream ApplyFilterForStreamReader(StreamReader inputReader, string entitySetOrSingleton, XslCompiledTransform transform) | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| Stream stream; | ||||||||||||||||||||||||
| StreamReader inputReader = new(csdl); | ||||||||||||||||||||||||
| XmlReader inputXmlReader = XmlReader.Create(inputReader); | ||||||||||||||||||||||||
| MemoryStream filteredStream = new(); | ||||||||||||||||||||||||
| StreamWriter writer = new(filteredStream); | ||||||||||||||||||||||||
| XsltArgumentList args = new(); | ||||||||||||||||||||||||
| args.AddParam("entitySetOrSingleton", "", entitySetOrSingleton); | ||||||||||||||||||||||||
| transform.Transform(inputXmlReader, args, writer); | ||||||||||||||||||||||||
| stream = filteredStream; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return stream; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslCompiledTransform transform) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| StreamReader inputReader = new(csdl); | ||||||||||||||||||||||||
Check warningCode scanning / CodeQL Missing Dispose call on local IDisposable
Disposable 'StreamReader' is created but not disposed.
|
||||||||||||||||||||||||
| return ApplyFilterForStreamReader(inputReader, entitySetOrSingleton, transform); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private static Stream ApplyFilter(Stream csdlStream, string entitySetOrSingleton, XslCompiledTransform transform) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| StreamReader inputReader = new(csdlStream); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| return ApplyFilterForStreamReader(inputReader, entitySetOrSingleton, transform); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+252
to
+263
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||
| /// Implementation of the validate command | ||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code here seems wrong. GetStream does all the logic to determine if stream is coming from a file or via HTTP. Currently the code is getting the stream and then ignoring it if there is a filter. The solution should be to change ApplyFilter to just accept the stream that comes from GetStream. And the case-insensitive check needs to be added to GetStream.
I'm not sure why the OP closed the PR. This seems like a good thing to fix.