@@ -148,7 +148,7 @@ def protect(self, value: str, policy_name: str) -> str:
148148 def access (self , protected_value : str , policy_name : str = None ) -> str :
149149 if policy_name :
150150 policy = self ._get_policy (policy_name )
151- return self ._access_fpe (protected_value , policy )
151+ return self ._access_fpe (protected_value , policy , explicit_policy = True )
152152
153153 # Tag-based lookup — longest tags first
154154 for tag in sorted (self ._tag_index .keys (), key = len , reverse = True ):
@@ -185,16 +185,16 @@ def _protect_fpe(self, value: str, policy: dict, is_ff3: bool) -> str:
185185 return policy ["tag" ] + result
186186 return result
187187
188- def _access_fpe (self , protected_value : str , policy : dict ) -> str :
188+ def _access_fpe (self , protected_value : str , policy : dict , explicit_policy : bool = False ) -> str :
189189 if policy ["engine" ] not in ("ff1" , "ff3" ):
190190 raise ValueError (f"Cannot reverse '{ policy ['engine' ]} ' — not reversible" )
191191
192192 key = self ._resolve_key (policy ["key_ref" ])
193193 alphabet = policy ["alphabet" ]
194194
195- # Strip tag
195+ # Strip tag (only when auto-detected, not when policy explicitly provided)
196196 without_tag = protected_value
197- if policy ["tag_enabled" ] and policy ["tag" ]:
197+ if not explicit_policy and policy ["tag_enabled" ] and policy ["tag" ]:
198198 without_tag = protected_value [len (policy ["tag" ]):]
199199
200200 # Strip passthroughs
0 commit comments