Commit e461c01f60c7791c33849ed5a9e31c6cbaf8e5d4
1 parent
8336fb93
Exists in
master
and in
112 other branches
Improve VOTable parser
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
php/classes/EpnTapMgr.php
... | ... | @@ -19,7 +19,10 @@ class EpnTapMgr { |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function JDTodate($jd) { |
22 | - list($month, $day, $year) = preg_split('/[\s\/:]+/', JDToGregorian($jd)); | |
22 | + if(!is_numeric($jd)) { | |
23 | + return ''; | |
24 | + } | |
25 | + list($month, $day, $year) = preg_split('/[\s\/:]+/', JDToGregorian(intval($jd))); | |
23 | 26 | $date = sprintf('%02d', $day) . '/' . sprintf('%02d', $month) . '/' . sprintf('%04d', $year); |
24 | 27 | return ($date == '00/00/0000') ? '' : $date; |
25 | 28 | } |
... | ... | @@ -40,7 +43,7 @@ class EpnTapMgr { |
40 | 43 | public function request($access_url, $query) { |
41 | 44 | $votMgr = new VOTableMgr; |
42 | 45 | $params = 'FORMAT=votable&LANG=ADQL&REQUEST=doQuery'; |
43 | - $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode($query); | |
46 | + $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode(preg_replace('/\s+/', ' ', $query)); // remove also multiple whitespaces | |
44 | 47 | |
45 | 48 | $res = $votMgr->load($url); |
46 | 49 | $this->addLog("Query URL: " . $url); |
... | ... |
php/classes/VOTableMgr.php
... | ... | @@ -359,8 +359,9 @@ class VOTableMgr { |
359 | 359 | $res = $b == "T" || $b == "t" || $b == "1"; |
360 | 360 | break; |
361 | 361 | case 'char': |
362 | + $res = $row_size!=0 ? utf8_encode($substr) : NULL; | |
362 | 363 | case 'unicodeChar': |
363 | - $res = $row_size!=0 ? $substr : NULL; | |
364 | + $res = $row_size!=0 ? utf8_encode(str_replace("\0", "", $substr)) : NULL; | |
364 | 365 | break; |
365 | 366 | case 'short': |
366 | 367 | $res = unpack("ss", $substr)["s"]; |
... | ... |