c4rlo / vimhelp

Google App Engine based project which regularly generates HTML versions of the Vim help files
https://vimhelp.org
MIT License
83 stars 9 forks source link

Fix potential infinite loop in synthesize_tag when handling duplicates #24

Closed ychin closed 1 year ago

ychin commented 1 year ago

When vimhelp encounters a duplicate tag in synthesizetag(), it tries to de-duplicate by adding ``. There's a bug in the current logic which leads to an infinite loop. This fixes that. There currently isn't any vim documentation that exhibits this issue.

Note: To reproduce this, just apply the following patch to Vim's docs and run the script and you will see that it hangs:

diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index 724318dfd..3ac6684c6 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -1069,7 +1069,7 @@ Note that a menu that starts with ']' will not be displayed.

 This section describes font related options.

-GUIFONT                                                        *gui-font*
+GUIFONT                                                        *_font*

 'guifont' is the option that tells Vim what font to use.  In its simplest form
 the value is just one font name.  It can also be a list of font names
c4rlo commented 1 year ago

Thank you!