[Buildbot-commits] buildbot/buildbot/status html.py,1.79,1.80 builder.py,1.74,1.75

Brian Warner warner at users.sourceforge.net
Mon Jan 23 23:03:29 UTC 2006


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11310/buildbot/status

Modified Files:
	html.py builder.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-460
Creator:  Brian Warner <warner at lothar.com>

allow spaces and slashes in Builder names (and their URLs)

	* buildbot/status/builder.py: urllib.quote() all URLs that include
	Builder names, so that builders can include characters like '/'
	and ' ' without completely breaking the resulting HTML. Thanks to
	Kevin Turner for the patch.
	* buildbot/status/html.py: same
	* buildbot/test/test_web.py (GetURL.testBuild): match changes


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- builder.py	3 Jan 2006 09:26:41 -0000	1.74
+++ builder.py	23 Jan 2006 23:03:26 -0000	1.75
@@ -7,7 +7,7 @@
 from twisted.internet import reactor, defer
 from twisted.protocols import basic
 
-import time, os, os.path, shutil, sys, re
+import time, os, os.path, shutil, sys, re, urllib
 try:
     import cPickle as pickle
 except ImportError:
@@ -1762,21 +1762,23 @@
             pass
         if providedBy(thing, interfaces.IBuilderStatus):
             builder = thing
-            return prefix + builder.getName()
+            return prefix + urllib.quote(builder.getName(), safe='')
         if providedBy(thing, interfaces.IBuildStatus):
             build = thing
             builder = build.getBuilder()
-            return "%s%s/builds/%d" % (prefix,
-                                       builder.getName(),
-                                       build.getNumber())
+            return "%s%s/builds/%d" % (
+                prefix,
+                urllib.quote(builder.getName(), safe=''),
+                build.getNumber())
         if providedBy(thing, interfaces.IBuildStepStatus):
             step = thing
             build = step.getBuild()
             builder = build.getBuilder()
-            return "%s%s/builds/%d/%s" % (prefix,
-                                          builder.getName(),
-                                          build.getNumber(),
-                                          "step-" + step.getName())
+            return "%s%s/builds/%d/%s" % (
+                prefix,
+                urllib.quote(builder.getName(), safe=''),
+                build.getNumber(),
+                "step-" + urllib.quote(step.getName(), safe=''))
         # IBuildSetStatus
         # IBuildRequestStatus
         # ISlaveStatus
@@ -1802,11 +1804,12 @@
                     break
             else:
                 return None
-            return "%s%s/builds/%d/%s/%d" % (prefix,
-                                             builder.getName(),
-                                             build.getNumber(),
-                                             "step-" + step.getName(),
-                                             lognum)
+            return "%s%s/builds/%d/%s/%d" % (
+                prefix,
+                urllib.quote(builder.getName(), safe=''),
+                build.getNumber(),
+                "step-" + urllib.quote(step.getName(), safe=''),
+                lognum)
 
 
     def getSchedulers(self):

Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- html.py	13 Jan 2006 08:34:28 -0000	1.79
+++ html.py	23 Jan 2006 23:03:26 -0000	1.80
@@ -220,6 +220,11 @@
                      "<ul>\n")
             for num in range(len(logs)):
                 if logs[num].hasContents():
+                    # FIXME: If the step name has a / in it, this is broken
+                    # either way.  If we quote it but say '/'s are safe,
+                    # it chops up the step name.  If we quote it and '/'s
+                    # are not safe, it escapes the / that separates the
+                    # step name from the log number.
                     data += '<li><a href="%s">%s</a></li>\n' % \
                             (urllib.quote(request.childLink("%d" % num)),
                              html.escape(logs[num].getName()))
@@ -321,7 +326,7 @@
         data += ("<h1>Build <a href=\"%s\">%s</a>:#%d</h1>\n"
                  "<h2>Reason:</h2>\n%s\n"
                  % (self.status.getURLForThing(b.getBuilder()),
-                    urllib.quote(b.getBuilder().getName()), b.getNumber(),
+                    b.getBuilder().getName(), b.getNumber(),
                     html.escape(b.getReason())))
 
         branch, revision, patch = b.getSourceStamp()
@@ -912,8 +917,8 @@
         b = self.original
         name = b.getBuilder().getName()
         number = b.getNumber()
-        url = "%s/builds/%d" % (name, number)
-        text = '<a href="%s">Build %d</a>' % (urllib.quote(url), number)
+        url = "%s/builds/%d" % (urllib.quote(name, safe=''), number)
+        text = '<a href="%s">Build %d</a>' % (url, number)
         color = "yellow"
         class_ = "start"
         if b.isFinished() and not b.getSteps():
@@ -933,9 +938,10 @@
 
     def getBox(self):
         b = self.original.getBuild()
-        urlbase = "%s/builds/%d/step-%s" % (b.getBuilder().getName(),
-                                            b.getNumber(),
-                                            self.original.getName())
+        urlbase = "%s/builds/%d/step-%s" % (
+            urllib.quote(b.getBuilder().getName(), safe=''),
+            b.getNumber(),
+            urllib.quote(self.original.getName(), safe=''))
         text = self.original.getText()
         if text is None:
             log.msg("getText() gave None", urlbase)
@@ -945,7 +951,7 @@
         for num in range(len(logs)):
             name = logs[num].getName()
             if logs[num].hasContents():
-                url = urllib.quote("%s/%d" % (urlbase, num))
+                url = "%s/%d" % (urlbase, num)
                 text.append("<a href=\"%s\">%s</a>" % (url, html.escape(name)))
             else:
                 text.append(html.escape(name))
@@ -1122,12 +1128,12 @@
         data += td("time (%s)" % TZ, align="center", class_="Time")
         name = changeNames[0]
         data += td(
-                "<a href=\"%s\">%s</a>" % (urllib.quote(name), name),
+                "<a href=\"%s\">%s</a>" % (urllib.quote(name, safe=''), name),
                 align="center", class_="Change")
         for name in builderNames:
             data += td(
                 #"<a href=\"%s\">%s</a>" % (request.childLink(name), name),
-                "<a href=\"%s\">%s</a>" % (urllib.quote(name), name),
+                "<a href=\"%s\">%s</a>" % (urllib.quote(name, safe=''), name),
                 align="center", class_="Builder")
         data += " </tr>\n"
 





More information about the Commits mailing list