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

Throw exception when empty inputs found #169

Merged
merged 3 commits into from
Nov 5, 2019
Merged

Conversation

DeepDiver1975
Copy link
Member

When input retrieved from stream_get_contents
is empty string, then it would be safe to throw
exceptions from the parse and expect methods.

Signed-off-by: Sujith H sharidasan@owncloud.com

master version of #166

sharidas and others added 2 commits August 14, 2019 17:45
When input retrieved from stream_get_contents
is empty string, then it would be safe to throw
exceptions from the parse and expect methods.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
@codecov
Copy link

codecov bot commented Aug 14, 2019

Codecov Report

Merging #169 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #169      +/-   ##
===========================================
+ Coverage     97.58%   97.6%   +0.02%     
- Complexity      112     114       +2     
===========================================
  Files            13      13              
  Lines           456     460       +4     
===========================================
+ Hits            445     449       +4     
  Misses           11      11
Impacted Files Coverage Δ Complexity Δ
lib/Service.php 100% <100%> (ø) 20 <0> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8e9bb3...cafb5c0. Read the comment docs.

@DeepDiver1975 DeepDiver1975 self-assigned this Aug 19, 2019
@DeepDiver1975
Copy link
Member Author

@staabm mind reviewing? THX


// If input is an empty string, then its safe to throw exception
if ('' === $input) {
throw new ParseException('The input element to parse is empty. Do not attempt to parse');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I get the meaning of this error message? what do you try to tell the caller?

@@ -115,6 +115,11 @@ public function parse($input, string $contextUri = null, string &$rootElementNam
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
$input = (string) stream_get_contents($input);

// If input is an empty string, then its safe to throw exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should mention that we get into an infinite loop when we don't throw

Copy link
Member

@staabm staabm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the textual nits, it looks good to me.

thanks

@DeepDiver1975
Copy link
Member Author

FYI - this is just the merge of the original PR which targeted 2.1 - see #166

@DeepDiver1975 DeepDiver1975 merged commit 334e84a into master Nov 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the port/166-master branch November 5, 2019 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants