[tracker/wip/carlosg/deserialize-api: 8/17] libtracker-sparql: Fix handling of graph clauses in Trig parser




commit 3260379e9c51812b0881026cb636c82d4a6d0fb3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 8 00:07:59 2022 +0200

    libtracker-sparql: Fix handling of graph clauses in Trig parser
    
    These graphs may also come in PNAME_LN and PNAME_NS forms, like other
    IRIs. Add this missing handling.

 src/libtracker-sparql/tracker-deserializer-turtle.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-deserializer-turtle.c 
b/src/libtracker-sparql/tracker-deserializer-turtle.c
index 1670217ef..98d973458 100644
--- a/src/libtracker-sparql/tracker-deserializer-turtle.c
+++ b/src/libtracker-sparql/tracker-deserializer-turtle.c
@@ -509,19 +509,26 @@ tracker_deserializer_turtle_iterate_next (TrackerDeserializerTurtle  *deserializ
                        }
                        break;
                case STATE_GRAPH:
+                       g_clear_pointer (&deserializer->graph, g_free);
+
                        if (parse_token (deserializer, "graph")) {
                                advance_whitespace_and_comments (deserializer);
 
                                if (parse_terminal (deserializer, terminal_IRIREF, 1, &str)) {
                                        deserializer->graph = expand_base (deserializer, str);
+                               } else if (parse_terminal (deserializer, terminal_PNAME_LN, 0, &str) ||
+                                          parse_terminal (deserializer, terminal_PNAME_NS, 0, &str)) {
+                                       deserializer->graph = expand_prefix (deserializer, str, error);
+                                       g_free (str);
+                                       if (!deserializer->graph)
+                                               return FALSE;
                                } else {
                                        g_set_error (error,
                                                     TRACKER_SPARQL_ERROR,
                                                     TRACKER_SPARQL_ERROR_PARSE,
                                                     "Wrong graph token");
+                                       return FALSE;
                                }
-                       } else {
-                               g_clear_pointer (&deserializer->graph, g_free);
                        }
 
                        advance_whitespace_and_comments (deserializer);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]