Skip to content

Commit

Permalink
Merge pull request #247 from FairfieldTekLLC/master
Browse files Browse the repository at this point in the history
Fixed for indexing strings out of bounds
  • Loading branch information
JonathanMagnan authored Sep 21, 2018
2 parents 3a6f0d2 + ac0507d commit e2ecdb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/HtmlAgilityPack.Shared/HtmlAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ public string Value

if (_value == null)
{
_value = _ownerdocument.Text.Substring(_valuestartindex, _valuelength);
if (_ownerdocument.Text != null && _valuestartindex + _valuelength <= _ownerdocument.Text.Length)
_value = _ownerdocument.Text.Substring(_valuestartindex, _valuelength);
else
_value = "";

if (!_ownerdocument.BackwardCompatibility)
{
Expand Down
4 changes: 3 additions & 1 deletion src/HtmlAgilityPack.Shared/HtmlNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ public virtual string OuterHtml
return string.Empty;
}

return _ownerdocument.Text.Substring(_outerstartindex, _outerlength);
if (_ownerdocument.Text != null && _outerstartindex + _outerlength <= _ownerdocument.Text.Length)
return _ownerdocument.Text.Substring(_outerstartindex, _outerlength);
return string.Empty;
}
}

Expand Down

0 comments on commit e2ecdb6

Please sign in to comment.