summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-23 15:50:50 +0000
committerGerrit Code Review <review@openstack.org>2022-08-23 15:50:50 +0000
commitf3978d3b4ece437799a87969283c3ff7ccd30846 (patch)
treea5f64a3d442da9a1a16a4080b1704937e3df13ca
parent7b68214ea6ba683ede44d500cd37844e6e85b675 (diff)
parent9e88f8e5cb5f54a0f304f6b94898f943b1b53fcc (diff)
downloadzuul-f3978d3b4ece437799a87969283c3ff7ccd30846.tar.gz
Merge "Fix links for jobs with special characters"
-rw-r--r--tests/fixtures/layouts/special-characters-job.yaml2
-rw-r--r--tests/unit/test_web.py5
-rw-r--r--web/src/containers/jobs/Jobs.jsx2
-rwxr-xr-xzuul/web/__init__.py2
4 files changed, 10 insertions, 1 deletions
diff --git a/tests/fixtures/layouts/special-characters-job.yaml b/tests/fixtures/layouts/special-characters-job.yaml
new file mode 100644
index 000000000..20308c6d6
--- /dev/null
+++ b/tests/fixtures/layouts/special-characters-job.yaml
@@ -0,0 +1,2 @@
+- job:
+ name: "a@b/c"
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index 53546c1de..ba1931436 100644
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -1005,6 +1005,11 @@ class TestWeb(BaseTestWeb):
job = self.get_url("api/tenant/tenant-one/job/noop").json()
self.assertEqual("noop", job[0]["name"])
+ @simple_layout('layouts/special-characters-job.yaml')
+ def test_web_job_special_characters(self):
+ job = self.get_url("api/tenant/tenant-one/job/a%40b%2Fc").json()
+ self.assertEqual("a@b/c", job[0]["name"])
+
def test_freeze_jobs(self):
# Test can get a list of the jobs for a given project+pipeline+branch.
resp = self.get_url(
diff --git a/web/src/containers/jobs/Jobs.jsx b/web/src/containers/jobs/Jobs.jsx
index d7ab4bc69..71395f1d1 100644
--- a/web/src/containers/jobs/Jobs.jsx
+++ b/web/src/containers/jobs/Jobs.jsx
@@ -62,7 +62,7 @@ class JobsList extends React.Component {
const createNode = (job, extra) => ({
text: (
<React.Fragment>
- <Link to={linkPrefix + job.name}>{job.name}</Link>
+ <Link to={linkPrefix + encodeURIComponent(job.name)}>{job.name}</Link>
{extra && (<span> ({extra})</span>)}
{job.description && (
<span style={{marginLeft: '10px'}}>{job.description}</span>
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index f06dd0b52..644b82bec 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -32,6 +32,7 @@ import ssl
import threading
import uuid
import prometheus_client
+import urllib.parse
import zuul.executor.common
from zuul import exceptions
@@ -1170,6 +1171,7 @@ class ZuulWebAPI(object):
@cherrypy.tools.json_out(
content_type='application/json; charset=utf-8', handler=json_handler)
def job(self, tenant_name, job_name):
+ job_name = urllib.parse.unquote_plus(job_name)
tenant = self._getTenantOrRaise(tenant_name)
job_variants = tenant.layout.jobs.get(job_name)
result = []