Skip to content

fix quadratic scan in XMLUtil::GetCharacterRef - #1102

Open
darshan-mog wants to merge 1 commit into
leethomason:masterfrom
darshan-mog:charref-linear-scan
Open

darshan-mog wants to merge 1 commit into
leethomason:masterfrom
darshan-mog:charref-linear-scan

Conversation

@darshan-mog

Copy link
Copy Markdown

XMLUtil::GetCharacterRef finds the end of a numeric character reference with strchr(';'), which scans the rest of the text or attribute value for every "&#", so unterminated references make GetText()/Attribute() quadratic: a 1 MB text node of "&#" repeated takes 11.8 s, 2.7 ms after this change. The same strchr also let a stray 'x' or '#' end the digit run, so "&#x12x41;" and "&#A" were silently resolved to "A"; scanning forward over radix digits only and rejecting on the first non-digit fixes both, with regression tests in xmltest.

This branch has not been deployed

No deployments
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.

1 participant