View Single Post
Old 04-28-2025, 02:21 PM   #10665
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,043
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by icecold View Post
It seems like something about my add_to_replace_metadata section is causing the issue. If I remove that portion, I can download fics is just fine. I'm not sure if it's a bit of very promblematic regex or it it's the sheer length length of it.
I think using that many lines is kinda crazy, but it should still work. (And I suspect you will get unintended substitutions if you stray from your currently preferred fandoms, but that's not a technical issue.)

Regardless, I, too, saw it hang with these settings.

I added some instrumentation to the code and found that the regex search was getting hung on replacement line(s) with leading (?:.*.)*? such as:
Code:
 characters,ships=>(?:.*.)*?Amber=>HI3.Amber
Removing that line, just moved it down to the next one. It also only happens when the input string is 'long enough'--in this case "Golden Deer Students (Fire Emblem)"

Replacing all (?:.*.)*? (which is honestly a bit nonsensical) with (?:.*\.)*? (which I don't understand the purpose, but works in other lines) seems to fix the problem:

Code:
 characters,ships=>(?:.*\.)*?Amber=>HI3.Amber
This isn't FFF specific, it's happening in python's regexp engine:
Code:
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> val = "Golden Deer Students (Fire Emblem)"
>>> rep = re.compile(r'(?:.*.)*?Amber=>HI3.Amber')
>>> rep.search(val)
(hangs indefinitely)
Using regex101.com, it reports "Catastrophic backtracking". See https://regex101.com/r/A9HEGn/1

Why Python doesn't detect and report that, I don't know.

So, basically, don't use (?:.*.)*?.
JimmXinu is offline   Reply With Quote