-
Notifications
You must be signed in to change notification settings - Fork 77
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
Conversation
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 Report
@@ 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
Continue to review full report at Codecov.
|
@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'); |
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.
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 |
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.
we should mention that we get into an infinite loop when we don't throw
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.
without the textual nits, it looks good to me.
thanks
FYI - this is just the merge of the original PR which targeted 2.1 - see #166 |
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