Prevent server_add autocomplete from being interpreted as UTF-7. Fixes #1871.

This commit is contained in:
Bharat Mediratta
2012-05-16 12:26:09 -07:00
parent 790f64cbcf
commit 88c0363344
2 changed files with 18 additions and 2 deletions

View File

@@ -71,14 +71,13 @@ class Admin_Server_Add_Controller extends Admin_Controller {
}
public function autocomplete() {
$directories = array();
$directories = array('<meta http-equiv="content-type" content="text/html; charset=utf-8">');
$path_prefix = Input::instance()->get("q");
foreach (glob("{$path_prefix}*") as $file) {
if (is_dir($file) && !is_link($file)) {
$directories[] = html::clean($file);
}
}
print implode("\n", $directories);
}

View File

@@ -9,6 +9,23 @@ $("document").ready(function() {
{
max: 256,
loadingClass: "g-loading-small",
parse: function(data) {
var parsed = [];
var rows = data.split("\n");
rows.shift(); // drop <META> tag
for (var i=0; i < rows.length; i++) {
var row = $.trim(rows[i]);
if (row) {
row = row.split("|");
parsed[parsed.length] = {
data: row,
value: row[0],
result: row[0]
};
}
}
return parsed;
}
});
});
</script>