mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix CFI parsing of numbers with trailing zeros
Fixes #2029521 [Epub files with non-functional bookmarks](https://bugs.launchpad.net/calibre/+bug/2029521)
This commit is contained in:
parent
db540da647
commit
ccb6781005
@ -26,7 +26,7 @@ class Parser:
|
||||
# No leading zeros allowed for integers
|
||||
integer = r'(?:[1-9][0-9]*)|0'
|
||||
# No leading zeros, except for numbers in (0, 1) and no trailing zeros for the fractional part
|
||||
frac = r'\.[0-9]*[1-9]'
|
||||
frac = r'\.[0-9]{1,}'
|
||||
number = r'(?:[1-9][0-9]*(?:{0})?)|(?:0{0})|(?:0)'.format(frac)
|
||||
def c(x):
|
||||
return regex.compile(x, flags=regex.VERSION1)
|
||||
@ -239,3 +239,8 @@ def decode_cfi(root, cfi):
|
||||
else:
|
||||
return
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
print(cfi_sort_key(sys.argv[-1], only_path=False))
|
||||
|
@ -79,6 +79,7 @@ class Tests(unittest.TestCase):
|
||||
('/1~0.01', o('~', 0.01), ''),
|
||||
('/1~1.301', o('~', 1.301), ''),
|
||||
('/1@23:34.1', o('@', (23, 34.1)), ''),
|
||||
('/1@23:34.10', o('@', (23, 34.1)), ''),
|
||||
('/1~3@3.1:2.3', o('~', 3.0, '@', (3.1, 2.3)), ''),
|
||||
('/1:0', o(':', 0), ''),
|
||||
('/1:3', o(':', 3), ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user