mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-10-26 08:12:25 -04:00 
			
		
		
		
	Make CodeQL happy
Tighten up a few regexes
This commit is contained in:
		
							parent
							
								
									cb3ae447dc
								
							
						
					
					
						commit
						60eb111ef4
					
				| @ -351,7 +351,7 @@ OEB_IMAGES        = {GIF_MIME, JPEG_MIME, PNG_MIME, SVG_MIME} | |||||||
| 
 | 
 | ||||||
| MS_COVER_TYPE = 'other.ms-coverimage-standard' | MS_COVER_TYPE = 'other.ms-coverimage-standard' | ||||||
| 
 | 
 | ||||||
| ENTITY_RE     = re.compile(r'&([a-zA-Z_:][a-zA-Z0-9.-_:]+);') | ENTITY_RE     = re.compile(r'&([a-zA-Z_:][a-zA-Z0-9._:-]+);') | ||||||
| COLLAPSE_RE   = re.compile(r'[ \t\r\n\v]+') | COLLAPSE_RE   = re.compile(r'[ \t\r\n\v]+') | ||||||
| QNAME_RE      = re.compile(r'^[{][^{}]+[}][^{}]+$') | QNAME_RE      = re.compile(r'^[{][^{}]+[}][^{}]+$') | ||||||
| PREFIXNAME_RE = re.compile(r'^[^:]+[:][^:]+') | PREFIXNAME_RE = re.compile(r'^[^:]+[:][^:]+') | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ import re | |||||||
| 
 | 
 | ||||||
| from qt.core import QApplication, QBrush, QColor, QFont, QSyntaxHighlighter, QTextCharFormat, QTextCursor, QTextLayout | from qt.core import QApplication, QBrush, QColor, QFont, QSyntaxHighlighter, QTextCharFormat, QTextCursor, QTextLayout | ||||||
| 
 | 
 | ||||||
|  | from calibre.ebooks.oeb.base import ENTITY_RE | ||||||
| from calibre.gui2.palette import dark_link_color, light_link_color | from calibre.gui2.palette import dark_link_color, light_link_color | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -31,7 +32,7 @@ class MarkdownHighlighter(QSyntaxHighlighter): | |||||||
|         'HeaderLine': re.compile(r'(?u)^(-|=)+\s*$'), |         'HeaderLine': re.compile(r'(?u)^(-|=)+\s*$'), | ||||||
|         'HR': re.compile(r'(?u)^(\s*(\*|-|_)\s*){3,}$'), |         'HR': re.compile(r'(?u)^(\s*(\*|-|_)\s*){3,}$'), | ||||||
|         'Html': re.compile(r'(?u)</?[^/\s].*?(?<!\\)>'), |         'Html': re.compile(r'(?u)</?[^/\s].*?(?<!\\)>'), | ||||||
|         'Entity': re.compile(r'&([A-z]{2,7}|#\d{1,7}|#x[\dA-Fa-f]{1,6});'), |         'Entity': ENTITY_RE, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     key_theme_maps = { |     key_theme_maps = { | ||||||
|  | |||||||
| @ -823,12 +823,11 @@ class TextEdit(PlainTextEdit): | |||||||
|             return self.text_for_range(c.block(), r) |             return self.text_for_range(c.block(), r) | ||||||
| 
 | 
 | ||||||
|     def select_class_name_at_cursor(self, cursor): |     def select_class_name_at_cursor(self, cursor): | ||||||
|         valid = re.compile(r'[\w_0-9\-]+', flags=re.UNICODE) |         valid = re.compile(r'^[\w_-]+$', flags=re.UNICODE) | ||||||
| 
 | 
 | ||||||
|         def keep_going(): |         def keep_going(): | ||||||
|             q = cursor.selectedText() |             q = cursor.selectedText() | ||||||
|             m = valid.match(q) |             return valid.match(q) is not None | ||||||
|             return m is not None and m.group() == q |  | ||||||
| 
 | 
 | ||||||
|         def run_loop(forward=True): |         def run_loop(forward=True): | ||||||
|             cursor.setPosition(pos) |             cursor.setPosition(pos) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user