Skip to content

Commit

Permalink
implemented a new WebUI patch to force addon version download URLs to
Browse files Browse the repository at this point in the history
carry a valid text/plain content-type no matter what the corresponding
addon URL returns. This fixes #480.
  • Loading branch information
jens-maus committed Nov 25, 2018
1 parent 90198e5 commit 045fa6c
Show file tree
Hide file tree
Showing 3 changed files with 1,101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- occu/WebUI/www/config/cp_software.cgi.orig
+++ occu/WebUI/www/config/cp_software.cgi
@@ -452,18 +452,21 @@
puts "<script type=\"text/javascript\">translatePage('#messagebox')</script>"
global swVersion swUpdate
cgi_javascript {
+ puts "function getVersion(url, callback) {"
+ puts " var xhr = new XMLHttpRequest();"
+ puts " xhr.onreadystatechange = function () {"
+ puts " if (xhr.readyState === 4 && xhr.status === 200) callback(xhr.responseText);"
+ puts " };"
+ puts " xhr.open(\"GET\", url, true);"
+ puts " xhr.overrideMimeType(\"text/plain; charset=iso-8859-1\");"
+ puts " xhr.send();"
+ puts "}"
for {set i 0} {$i <= $loop} {incr i} {
if { [info exists swUpdate($i)] } {
- puts "var anchor = document.getElementById(\"availableSWVersion_$i\");"
- puts "var iframe = document.createElement(\"iframe\");"
- puts "iframe.src = \"$swUpdate($i)?cmd=check_version&version=$swVersion($i)\";"
- puts "iframe.frameBorder=0;"
- puts "iframe.marginHeight=0;"
- puts "iframe.marginWidth=0;"
- puts "iframe.width=100;"
- puts "iframe.height=20;"
- puts "iframe.scrolling='no';"
- puts "anchor.appendChild(iframe);"
+ puts "getVersion(\"$swUpdate($i)?cmd=check_version&version=$swVersion($i)\", function(contents) {"
+ puts " document.getElementById(\"availableSWVersion_$i\").innerHTML = contents;"
+ puts "});"
+ puts "document.getElementById(\"availableSWVersion_$i\").innerHTML = \"n/a\";"
}
}
}
Loading

0 comments on commit 045fa6c

Please sign in to comment.