Skip to contentSkip to conversation

toaster: correctly handle quotes in project names

PATCH In review Elliot Smith 2 participants 3 messages Mar 9, 2016 – Mar 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: correctly handle quotes in project names

A project name like "Elliot's project" causes the "Rebuild" buttons in the most recent builds section to fail when clicked with:

Uncaught SyntaxError: Unexpected token ILLEGAL

This is because the single quote character causes the JavaScript for handling the button click event to be badly-formed.

As the project name is passed to the scheduleBuild() function but doesn't actually do anything, this can be fixed by removing the project name from the arguments passed to scheduleBuild() (as well as the project URL, which is also ignored).

---
 bitbake/lib/toaster/toastergui/templates/mrb_section.html | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/templates/mrb_section.html +1 -4
index 551e341..f43390f 100644
@@ -109,10 +109,7 @@
                       {%endif%}
                       pull-right"
                       onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
-                        {{build.project.name|json}},
-                        {% url 'project' build.project.id as purl %}{{purl|json}},
                         {{build.target_set.all|get_tasks|json}})'>
-
                         Rebuild
                   </button>
               {% endif %}
@@ -134,7 +131,7 @@
 
 <script>
 
-function scheduleBuild(url, projectName, projectUrl, buildlist) {
+function scheduleBuild(url, buildlist) {
   console.log("scheduleBuild");
   libtoaster.startABuild(url, null, buildlist.join(" "), function(){
     console.log("reloading page");
Signature · 12 lines
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#1 lore raw

I think this is fixed here already so much be better to just wait for the build cancel stuff to be merged?

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/diff/bitbake/lib/toaster/toastergui/static/js/mrbsection.js?h=michaelw/sujith/build-cancel&id=1dfe119322cc7ab35e489bc83f9bcc49b087b0c4

Michael

Quoted 42 lines · Elliot Smith

A project name like "Elliot's project" causes the "Rebuild" buttons in the most recent builds section to fail when clicked with:

Uncaught SyntaxError: Unexpected token ILLEGAL

This is because the single quote character causes the JavaScript for handling the button click event to be badly-formed.

As the project name is passed to the scheduleBuild() function but doesn't actually do anything, this can be fixed by removing the project name from the arguments passed to scheduleBuild() (as well as the project URL, which is also ignored).

---
  bitbake/lib/toaster/toastergui/templates/mrb_section.html | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/templates/mrb_section.html +1 -4
index 551e341..f43390f 100644
@@ -109,10 +109,7 @@
                        {%endif%}
                        pull-right"
                        onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
-                        {{build.project.name|json}},
-                        {% url 'project' build.project.id as purl %}{{purl|json}},
                          {{build.target_set.all|get_tasks|json}})'>
-
                          Rebuild
                    </button>
                {% endif %}
@@ -134,7 +131,7 @@
 
  <script>
 
-function scheduleBuild(url, projectName, projectUrl, buildlist) {
+function scheduleBuild(url, buildlist) {
    console.log("scheduleBuild");
    libtoaster.startABuild(url, null, buildlist.join(" "), function(){
      console.log("reloading page");
#2 lore raw

Great, yes, ignore my patch in that case.

Elliot

Quoted 62 lines · Michael Wood

I think this is fixed here already so much be better to just wait for the build cancel stuff to be merged?

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/diff/bitbake/lib/toaster/toastergui/static/js/mrbsection.js?h=michaelw/sujith/build-cancel&id=1dfe119322cc7ab35e489bc83f9bcc49b087b0c4

Michael

Quoted 37 lines · Elliot Smith

A project name like "Elliot's project" causes the "Rebuild" buttons in the most recent builds section to fail when clicked with:

Uncaught SyntaxError: Unexpected token ILLEGAL

This is because the single quote character causes the JavaScript for handling the button click event to be badly-formed.

As the project name is passed to the scheduleBuild() function but doesn't actually do anything, this can be fixed by removing the project name from the arguments passed to scheduleBuild() (as well as the project URL, which is also ignored).

---
  bitbake/lib/toaster/toastergui/templates/mrb_section.html | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -3
index 551e341..f43390f 100644
@@ -109,10 +109,7 @@
                        {%endif%}
                        pull-right"
                        onclick='scheduleBuild({% url 'projectbuilds'
 build.project.id as bpi %}{{bpi|json}},
-                        {{build.project.name|json}},
-                        {% url 'project' build.project.id as purl
 %}{{purl|json}},
                          {{build.target_set.all|get_tasks|json}})'>
-
                          Rebuild
                    </button>
                {% endif %}

bitbake/lib/toaster/toastergui/templates/mrb_section.html line 137

Quoted 7 lines
bitbake/lib/toaster/toastergui/templates/mrb_section.html +1 -0
@@ -134,7 +131,7 @@
    <script>
  -function scheduleBuild(url, projectName, projectUrl, buildlist) {
+function scheduleBuild(url, buildlist) {
    console.log("scheduleBuild");
    libtoaster.startABuild(url, null, buildlist.join(" "), function(){
      console.log("reloading page");
 

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre