comment_parser
comment_parser copied to clipboard
Infinite Loop
ff = ''' private String extractFileName(Header header) { if (header != null) { String value = header.getValue(); int start = value.indexOf(FILENAME_HEADER_PREFIX); if (start != -1) { value = value.substring(start + FILENAME_HEADER_PREFIX.length()); int end = value.indexOf('\"'); if (end != -1) { return value.substring(0, end); } } } return null; }'''
xx = comment_parser.extract_comments_from_str(ff,mime='text/x-java-source')
The script seems not able to preprocess this method. Specifically the problematic instruction is the bold one. Do you have any workarounds?
There is no infinite loop, the regex used to match literals in C-style code is very computationally expensive.
If you run the script for long enough (or shorten the code) it will eventually pass.
This is a result of https://github.com/jeanralphaviles/comment_parser/commit/7048f63f986fd1319bbd29e5f7952c7c2485997c, where I tweaked the regex to work on escaped strings. I'll have to come up with a less expensive regex.
I confirm that my previously parsed C code can no longer be parsed with comment_parser==v1.2.2
(even after 1 hour)