Skip to content

Conversation

@Rocketknight1
Copy link
Member

There's an exploitable regex in the donut processor, this replaces it with less blowup-prone code!

@Rocketknight1 Rocketknight1 marked this pull request as ready for review April 25, 2025 13:22
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1
Copy link
Member Author

cc @Michellehbn! I think this is simple enough and we should be able to merge it without too much trouble

Copy link
Contributor

@gante gante left a comment

Choose a reason for hiding this comment

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

LGTM 👍

potential_end = re.search(r">", tokens[potential_start.end() :], re.IGNORECASE)
if potential_end is None:
break
start_token = tokens[potential_start.start() : potential_start.end() + potential_end.end()]
Copy link
Contributor

@gante gante May 1, 2025

Choose a reason for hiding this comment

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

nit: I would add a comment (or create intermediary vars) to help explain the why behind potential_start.end() + potential_end.end() (potential_end searches over a substring)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good point! I rewrote that bit.

@Rocketknight1 Rocketknight1 force-pushed the fix-donut-backtracking branch from 43896b7 to 5a8abeb Compare May 6, 2025 16:03
@Rocketknight1 Rocketknight1 merged commit ebbe9b1 into main May 6, 2025
16 checks passed
@Rocketknight1 Rocketknight1 deleted the fix-donut-backtracking branch May 6, 2025 16:39
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Fix donut backtracking

* make fixup

* Trigger tests

* Remove old line

* Update code

* Fix reversed slice
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.

4 participants