Skip to content

Commit 61221f0

Browse files
author
Vladimir Kotal
committed
check URI
fixes #2446
1 parent 6796269 commit 61221f0

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

opengrok-tools/src/main/python/opengrok_tools/mirror.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
from .utils.opengrok import get_repos, get_config_value, get_repo_type
4343
from .utils.readconfig import read_config
4444
from .utils.repofactory import get_repository
45-
from .utils.utils import is_exe, check_create_dir, get_int, diff_list
45+
from .utils.utils import is_exe, check_create_dir, get_int, diff_list,\
46+
is_web_uri
4647
from .scm.repository import RepositoryException
4748

4849

@@ -51,7 +52,7 @@
5152
print("Need Python 3, you are running {}".format(major_version))
5253
sys.exit(1)
5354

54-
__version__ = "0.3"
55+
__version__ = "0.4"
5556

5657
# "constants"
5758
HOOK_TIMEOUT_PROPERTY = 'hook_timeout'
@@ -163,11 +164,10 @@ def main():
163164
check_create_dir(logger, logdir)
164165

165166
uri = args.uri
166-
if not uri:
167-
logger.error("URI of the web application not specified")
167+
if not is_web_uri(uri):
168+
logger.error("Not a URI: {}".format(uri))
168169
sys.exit(1)
169-
170-
logger.debug("URI = {}".format(uri))
170+
logger.debug("web application URI = {}".format(uri))
171171

172172
source_root = get_config_value(logger, 'sourceRoot', uri)
173173
if not source_root:

opengrok-tools/src/main/python/opengrok_tools/projadm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from .utils.filelock import Timeout, FileLock
4040
from .utils.opengrok import get_configuration, set_configuration, \
4141
add_project, delete_project, get_config_value
42-
from .utils.utils import get_command
42+
from .utils.utils import get_command, is_web_uri
4343

4444
MAJOR_VERSION = sys.version_info[0]
4545
if (MAJOR_VERSION < 3):
@@ -297,9 +297,10 @@ def main():
297297
sys.exit(1)
298298

299299
uri = args.uri
300-
if not uri:
301-
logger.error("URI of the webapp not specified")
300+
if not is_web_uri(uri):
301+
logger.error("Not a URI: {}".format(uri))
302302
sys.exit(1)
303+
logger.debug("web application URI = {}".format(uri))
303304

304305
lock = FileLock(os.path.join(tempfile.gettempdir(),
305306
os.path.basename(sys.argv[0]) + ".lock"))

opengrok-tools/src/main/python/opengrok_tools/sync.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from .utils.filelock import Timeout, FileLock
4444
from .utils.opengrok import list_indexed_projects, get_config_value
4545
from .utils.readconfig import read_config
46+
from .utils.utils import is_web_uri
4647

4748
major_version = sys.version_info[0]
4849
if (major_version < 3):
@@ -105,6 +106,9 @@ def main():
105106
logger = logging.getLogger(os.path.basename(sys.argv[0]))
106107

107108
uri = args.uri
109+
if not is_web_uri(uri):
110+
logger.error("Not a URI: {}".format(uri))
111+
sys.exit(1)
108112
logger.debug("web application URI = {}".format(uri))
109113

110114
# Changing working directory to root will avoid problems when running

0 commit comments

Comments
 (0)