Skip to content

Commit d96dbdf

Browse files
Handle parsing exception on files with percent signs (#793)
1 parent 99a13a3 commit d96dbdf

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from java.io import IOException
1010
from java.net import URI
11+
from java.net import URISyntaxException
1112
from java.security import NoSuchAlgorithmException
1213

1314
from oracle.weblogic.deploy.deploy import DeployException
@@ -328,36 +329,47 @@ def discard_current_edit():
328329
_logger.exiting(class_name=_class_name, method_name=_method_name)
329330
return
330331

332+
331333
def extract_from_uri(model_context, path_value):
332334
"""
333335
If the MBean path attribute has a URI file scheme, look past the scheme and
334-
resolve any global tokens.
336+
resolve any global tokens. If the filename contains non-standard RFC 2936 and
337+
does not represent a file but rather a future file.
335338
336339
:param model_context: current context containing job information
337340
:param path_value: MBean attribute path
338341
:return: fully resolved URI path, or the path_value if not a URI scheme
339342
"""
340-
uri = URI(path_value)
341-
if uri.getScheme() == 'file':
342-
return FILE_URI + model_context.replace_token_string(uri.getPath()[1:])
343+
_method_name = 'extract_from_uri'
344+
try:
345+
uri = URI(path_value)
346+
if uri.getScheme() == 'file':
347+
return FILE_URI + model_context.replace_token_string(uri.getPath()[1:])
348+
except URISyntaxException, use:
349+
_logger.fine('WLSDPLY-09113', path_value, use, class_name=_class_name, method_name=_method_name)
343350
return path_value
344351

345352

346353
def get_rel_path_from_uri(model_context, path_value):
347354
"""
348355
If the MBean attribute is a URI. To extract it from the archive, need to make
349-
it into a relative path.
356+
it into a relative path. If it contains non-standard RF 2396 characters, assume
357+
it is not a file name in the archive.
350358
:param model_context: current context containing run information
351359
:param path_value: the full value of the path attribute
352360
:return: The relative value of the path attribute
353361
"""
354-
uri = URI(path_value)
355-
if uri.getScheme() == 'file':
356-
value = model_context.tokenize_path(uri.getPath())
357-
if value.startswith(model_context.DOMAIN_HOME_TOKEN):
358-
# point past the token and first slash
359-
value = value[len(model_context.DOMAIN_HOME_TOKEN)+1:]
360-
return value
362+
_method_name = 'get_rel_path_from_uri'
363+
try:
364+
uri = URI(path_value)
365+
if uri.getScheme() == 'file':
366+
value = model_context.tokenize_path(uri.getPath())
367+
if value.startswith(model_context.DOMAIN_HOME_TOKEN):
368+
# point past the token and first slash
369+
value = value[len(model_context.DOMAIN_HOME_TOKEN)+1:]
370+
return value
371+
except URISyntaxException, use:
372+
_logger.fine('WLSDPLY-09113', path_value, use, class_name=_class_name, method_name=_method_name)
361373
return path_value
362374

363375

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,8 @@ WLSDPLY-09109=Unable to delete {0} {1}, name does not exist
10331033
WLSDPLY-09110=Deleting {0} {1}
10341034
WLSDPLY-09111=Unable to get delete item name for {0}
10351035
WLSDPLY-09112=Failed to discard current edit session: {0}
1036+
WLSDPLY-09113=Filenames contains unparseable characters {0} : {1}
1037+
10361038
# wlsdeploy/tool/deploy/deployer.py
10371039
WLSDPLY-09200=Error setting attribute {0} for {1} {2}: {3}
10381040
WLSDPLY-09201=Failed to get existing WLST value for model attribute {0} at location {1} because the \

0 commit comments

Comments
 (0)