88from pathlib import Path
99from typing import TYPE_CHECKING , ClassVar
1010
11+ from django .core .exceptions import ValidationError
1112from django .core .management .utils import find_command
1213from django .utils .translation import gettext_lazy
1314
@@ -104,6 +105,10 @@ def can_install(
104105 if component is None :
105106 return True
106107 path = cls .get_linguas_path (component )
108+ try :
109+ component .check_file_is_valid (path )
110+ except ValidationError :
111+ return False
107112 return bool (path ) and os .path .exists (path )
108113
109114 @staticmethod
@@ -145,6 +150,8 @@ def update_linguas(lines: list[str], codes: set[str]) -> tuple[bool, list[str]]:
145150 return changed , lines
146151
147152 def sync_linguas (self , component : Component , path : str ) -> bool :
153+ component .check_file_is_valid (path )
154+
148155 with open (path , encoding = "utf-8" ) as handle :
149156 lines = handle .readlines ()
150157
@@ -167,7 +174,11 @@ def post_add(
167174 ) -> None :
168175 with translation .component .repository .lock :
169176 path = self .get_linguas_path (translation .component )
170- if self .sync_linguas (translation .component , path ):
177+ try :
178+ changed = self .sync_linguas (translation .component , path )
179+ except ValidationError :
180+ return
181+ if changed :
171182 translation .addon_commit_files .append (path )
172183
173184 def daily_component (
@@ -177,7 +188,11 @@ def daily_component(
177188 ) -> None :
178189 with component .repository .lock :
179190 path = self .get_linguas_path (component )
180- if self .sync_linguas (component , path ):
191+ try :
192+ changed = self .sync_linguas (component , path )
193+ except ValidationError :
194+ return
195+ if changed :
181196 self .commit_and_push (component , [path ])
182197
183198
@@ -195,10 +210,12 @@ class UpdateConfigureAddon(GettextBaseAddon):
195210
196211 @staticmethod
197212 def get_configure_paths (component : Component ) -> Generator [str ]:
198- base = component .full_path
199213 for name in ("configure" , "configure.in" , "configure.ac" ):
200- path = os .path .join (base , name )
201- if os .path .exists (path ):
214+ try :
215+ path = component .get_validated_component_filename (name )
216+ except ValidationError :
217+ continue
218+ if path and os .path .exists (path ):
202219 yield path
203220
204221 @classmethod
0 commit comments