return g_quark_from_static_string ("gst-uri-error-quark");
}
+#define HEX_ESCAPE '%'
+
+#ifndef GST_REMOVE_DEPRECATED
static const guchar acceptable[96] = { /* X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF */
0x00, 0x3F, 0x20, 0x20, 0x20, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x22, 0x20, 0x3F, 0x3F, 0x1C, /* 2X !"#$%&'()*+,-./ */
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20, 0x20, 0x2C, 0x20, 0x2C, /* 3X 0123456789:;<=>? */
UNSAFE_SLASHES = 0x20 /* Allows all characters except for '/' and '%' */
} UnsafeCharacterSet;
-#define HEX_ESCAPE '%'
-
/* Escape undesirable characters using %
* -------------------------------------
*
return result;
}
-
-/* escape_string:
- * @string: string to be escaped
- *
- * Escapes @string, replacing any and all special characters
- * with equivalent escape sequences.
- *
- * Return value: a newly allocated string equivalent to @string
- * but with all special characters escaped
- **/
-static gchar *
-escape_string (const gchar * string)
-{
- return escape_string_internal (string, UNSAFE_ALL);
-}
+#endif
static int
hex_to_int (gchar c)
return unescaped;
}
+#ifdef GST_DISABLE_DEPRECATED
+gchar *gst_uri_construct (const gchar * protocol, const gchar * location);
+#endif
+
/**
* gst_uri_construct:
* @protocol: Protocol for URI
* Returns: (transfer full): a new string for this URI. Returns %NULL if the
* given URI protocol is not valid, or the given location is %NULL.
*/
+#ifndef GST_REMOVE_DEPRECATED
gchar *
gst_uri_construct (const gchar * protocol, const gchar * location)
{
g_return_val_if_fail (location != NULL, NULL);
proto_lowercase = g_ascii_strdown (protocol, -1);
- escaped = escape_string (location);
+ escaped = escape_string_internal (location, UNSAFE_PATH);
retval = g_strdup_printf ("%s://%s", proto_lowercase, escaped);
g_free (escaped);
g_free (proto_lowercase);
return retval;
}
+#endif
typedef struct
{
GST_END_TEST;
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+gchar *gst_uri_construct (const gchar * protocol, const gchar * location);
+#endif
+
+GST_START_TEST (test_gst_uri_construct)
+{
+ gchar *l;
+
+ /* URI with no protocol or empty protocol should return empty string */
+ ASSERT_CRITICAL (l = gst_uri_construct (NULL, "/path/to/file"));
+ fail_unless (l == NULL);
+ ASSERT_CRITICAL (l = gst_uri_construct ("", "/path/to/file"));
+ fail_unless (l == NULL);
+
+ /* URI with no location should return empty string */
+ ASSERT_CRITICAL (l = gst_uri_construct ("protocol", NULL));
+ fail_unless (l == NULL);
+
+ /* check the protocol for validity */
+ l = gst_uri_construct ("protocol1234567890+-.", "somefile");
+ fail_unless (l != NULL);
+ fail_unless_equals_string (l, "protocol1234567890+-.://somefile");
+ g_free (l);
+
+ /* check the location for correct handling */
+ l = gst_uri_construct ("aprotocol",
+ "/path+ to/some/file%d?akey=aval&key2=val2");
+ fail_unless (l != NULL);
+ fail_unless_equals_string (l,
+ "aprotocol:///path%2B%20to/some/file%25d?akey=aval&key2=val2");
+ g_free (l);
+}
+
+GST_END_TEST;
+#endif
+
#ifdef G_OS_WIN32
GST_START_TEST (test_win32_uri)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_protocol_case);
tcase_add_test (tc_chain, test_uri_get_location);
+#ifndef GST_REMOVE_DEPRECATED
+ tcase_add_test (tc_chain, test_gst_uri_construct);
+#endif
tcase_add_test (tc_chain, test_uri_misc);
tcase_add_test (tc_chain, test_element_make_from_uri);
#ifdef G_OS_WIN32