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

Avoid taking quadratic time #33

Merged
merged 1 commit into from
Aug 20, 2017
Merged
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
12 changes: 8 additions & 4 deletions src/parser/inlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,13 +859,14 @@ pub fn manual_scan_link_url(input: &str) -> Option<usize> {
if i < len && input.as_bytes()[i] == b'<' {
i += 1;
while i < len {
if input.as_bytes()[i] == b'>' {
let b = input.as_bytes()[i];
if b == b'>' {
i += 1;
break;
} else if input.as_bytes()[i] == b'\\' {
} else if b == b'\\' {
i += 2;
} else if isspace(input.as_bytes()[i]) {
return None;
} else if isspace(b) || b == b'<' {
return None
} else {
i += 1;
}
Expand All @@ -877,6 +878,9 @@ pub fn manual_scan_link_url(input: &str) -> Option<usize> {
} else if input.as_bytes()[i] == b'(' {
nb_p += 1;
i += 1;
if nb_p > 32 {
return None
}
} else if input.as_bytes()[i] == b')' {
if nb_p == 0 {
break;
Expand Down