mirror of
				https://github.com/miaowware/qrm2.git
				synced 2025-10-26 01:40:20 -04:00 
			
		
		
		
	Use str.isalnum and str.isdecimal instead of re.match for ?ae7q and ?qrz input validation
This commit is contained in:
		
							parent
							
								
									4ab4748b9f
								
							
						
					
					
						commit
						483a0bad19
					
				
							
								
								
									
										12
									
								
								exts/ae7q.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								exts/ae7q.py
									
									
									
									
									
								
							| @ -16,8 +16,6 @@ the GNU General Public License, version 2. | |||||||
| # KC4USA: reserved, no call history, *but* has application history | # KC4USA: reserved, no call history, *but* has application history | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| import re |  | ||||||
| 
 |  | ||||||
| import aiohttp | import aiohttp | ||||||
| from bs4 import BeautifulSoup | from bs4 import BeautifulSoup | ||||||
| 
 | 
 | ||||||
| @ -46,7 +44,7 @@ class AE7QCog(commands.Cog): | |||||||
|             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" |             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
| 
 | 
 | ||||||
|             if not re.match('[A-Z0-9]+$', callsign): |             if not callsign.isalnum(): | ||||||
|                 embed = cmn.embed_factory(ctx) |                 embed = cmn.embed_factory(ctx) | ||||||
|                 embed.title = "AE7Q History for Callsign" |                 embed.title = "AE7Q History for Callsign" | ||||||
|                 embed.colour = cmn.colours.bad |                 embed.colour = cmn.colours.bad | ||||||
| @ -120,7 +118,7 @@ class AE7QCog(commands.Cog): | |||||||
|             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" |             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
| 
 | 
 | ||||||
|             if not re.match('[A-Z0-9]+$', callsign): |             if not callsign.isalnum(): | ||||||
|                 embed = cmn.embed_factory(ctx) |                 embed = cmn.embed_factory(ctx) | ||||||
|                 embed.title = "AE7Q Trustee History for Callsign" |                 embed.title = "AE7Q Trustee History for Callsign" | ||||||
|                 embed.colour = cmn.colours.bad |                 embed.colour = cmn.colours.bad | ||||||
| @ -196,7 +194,7 @@ class AE7QCog(commands.Cog): | |||||||
|             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" |             base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
| 
 | 
 | ||||||
|             if not re.match('[A-Z0-9]+$', callsign): |             if not callsign.isalnum(): | ||||||
|                 embed = cmn.embed_factory(ctx) |                 embed = cmn.embed_factory(ctx) | ||||||
|                 embed.title = "AE7Q Application History for Callsign" |                 embed.title = "AE7Q Application History for Callsign" | ||||||
|                 embed.colour = cmn.colours.bad |                 embed.colour = cmn.colours.bad | ||||||
| @ -276,7 +274,7 @@ class AE7QCog(commands.Cog): | |||||||
|             base_url = "http://ae7q.com/query/data/FrnHistory.php?FRN=" |             base_url = "http://ae7q.com/query/data/FrnHistory.php?FRN=" | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
| 
 | 
 | ||||||
|             if not re.match('[0-9]+$', frn): |             if not frn.isdecimal(): | ||||||
|                 embed = cmn.embed_factory(ctx) |                 embed = cmn.embed_factory(ctx) | ||||||
|                 embed.title = "AE7Q History for FRN" |                 embed.title = "AE7Q History for FRN" | ||||||
|                 embed.colour = cmn.colours.bad |                 embed.colour = cmn.colours.bad | ||||||
| @ -347,7 +345,7 @@ class AE7QCog(commands.Cog): | |||||||
|             base_url = "http://ae7q.com/query/data/LicenseeIdHistory.php?ID=" |             base_url = "http://ae7q.com/query/data/LicenseeIdHistory.php?ID=" | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
| 
 | 
 | ||||||
|             if not re.match('[A-Z][0-9]+$', licensee_id, re.IGNORECASE): |             if not licensee_id.isalnum(): | ||||||
|                 embed = cmn.embed_factory(ctx) |                 embed = cmn.embed_factory(ctx) | ||||||
|                 embed.title = "AE7Q History for Licensee" |                 embed.title = "AE7Q History for Licensee" | ||||||
|                 embed.colour = cmn.colours.bad |                 embed.colour = cmn.colours.bad | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ the GNU General Public License, version 2. | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| from io import BytesIO | from io import BytesIO | ||||||
| import re |  | ||||||
| 
 | 
 | ||||||
| import aiohttp | import aiohttp | ||||||
| from lxml import etree | from lxml import etree | ||||||
| @ -32,7 +31,7 @@ class QRZCog(commands.Cog): | |||||||
|         """Looks up a callsign on [QRZ.com](https://www.qrz.com/). Add `--link` to only link the QRZ page.""" |         """Looks up a callsign on [QRZ.com](https://www.qrz.com/). Add `--link` to only link the QRZ page.""" | ||||||
|         flags = [f.lower() for f in flags] |         flags = [f.lower() for f in flags] | ||||||
| 
 | 
 | ||||||
|         if not re.match('[A-Z0-9]+$', callsign, re.IGNORECASE): |         if not callsign.isalnum(): | ||||||
|             embed = cmn.embed_factory(ctx) |             embed = cmn.embed_factory(ctx) | ||||||
|             embed.title = "QRZ Data for Callsign" |             embed.title = "QRZ Data for Callsign" | ||||||
|             embed.colour = cmn.colours.bad |             embed.colour = cmn.colours.bad | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user