ZOOM reject queries that cannot be char converted
[yaz-moved-to-github.git] / src / zoom-c.c
index d0f5042..290fb2f 100644 (file)
@@ -1635,12 +1635,19 @@ static zoom_ret ZOOM_connection_send_search(ZOOM_connection c)
             yaz_iconv_t cd = yaz_iconv_open(cp, "UTF-8");
             if (cd)
             {
+                int r;
                 search_req->query = yaz_copy_Z_Query(search_req->query,
                                                      c->odr_out);
                 
-                yaz_query_charset_convert_rpnquery(search_req->query->u.type_1,
-                                                   c->odr_out, cd);
+                r = yaz_query_charset_convert_rpnquery_check(
+                    search_req->query->u.type_1,
+                    c->odr_out, cd);
                 yaz_iconv_close(cd);
+                if (r)
+                {  /* query could not be char converted */
+                    set_ZOOM_error(c, ZOOM_ERROR_INVALID_QUERY, 0);
+                    return zoom_complete;
+                }
             }
         }
     }
@@ -1971,6 +1978,9 @@ static const char *return_record(ZOOM_record rec, int *len,
                 charset);
             if (ret_buf)
                 return ret_buf;
+            /* bad ISO2709. Return fail unless raw (ISO2709) is wanted */
+            if (marctype != YAZ_MARC_ISO2709)
+                return 0;
         }
         return return_string_record(rec, len,
                                     (const char *) r->u.octet_aligned->buf,