~ubuntu-branches/ubuntu/vivid/libinfinity/vivid-proposed

« back to all changes in this revision

Viewing changes to libinfinity/server/infd-directory.c

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2011-08-05 20:09:57 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110805200957-wpk147f6xnwnkhj8
Tags: 0.5.1-1
New upstream bugfix release, which fixes a crash in infinoted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1734
1734
                                      const gchar* name,
1735
1735
                                      GError** error)
1736
1736
{
 
1737
  gboolean has_sensible_character = FALSE;
 
1738
  const gchar* p;
 
1739
 
 
1740
  for (p = name; *p != '\0'; p = g_utf8_next_char(p))
 
1741
  {
 
1742
    if(!g_unichar_isprint(*p))
 
1743
    {
 
1744
      g_set_error(
 
1745
        error,
 
1746
        inf_directory_error_quark(),
 
1747
        INF_DIRECTORY_ERROR_INVALID_NAME,
 
1748
        _("Name \"%s\" is an invalid name: contains non-printable characters"),
 
1749
        name
 
1750
      );
 
1751
 
 
1752
      return FALSE;
 
1753
    }
 
1754
    else if(!g_unichar_isspace(*p))
 
1755
    {
 
1756
      has_sensible_character = TRUE;
 
1757
    }
 
1758
  }
 
1759
 
 
1760
  if(!has_sensible_character)
 
1761
  {
 
1762
    g_set_error(
 
1763
      error,
 
1764
      inf_directory_error_quark(),
 
1765
      INF_DIRECTORY_ERROR_INVALID_NAME,
 
1766
      _("Name \"%s\" is an invalid name: contains only space characters"),
 
1767
      name
 
1768
    );
 
1769
 
 
1770
    return FALSE;
 
1771
  }
 
1772
 
1737
1773
  if(strchr(name, '/') != NULL)
1738
1774
  {
1739
1775
    g_set_error(
1740
1776
      error,
1741
1777
      inf_directory_error_quark(),
1742
1778
      INF_DIRECTORY_ERROR_INVALID_NAME,
1743
 
      "Name \"%s\" is an invalid name: contains \"/\"",
 
1779
      _("Name \"%s\" is an invalid name: contains \"/\""),
1744
1780
      name
1745
1781
    );
1746
1782
 
1755
1791
      error,
1756
1792
      inf_directory_error_quark(),
1757
1793
      INF_DIRECTORY_ERROR_NODE_EXISTS,
1758
 
      "A node with name \"%s\" exists already",
 
1794
      _("A node with name \"%s\" exists already"),
1759
1795
      name
1760
1796
    );
1761
1797
 
2326
2362
  proxy = infd_directory_node_get_session(directory, node, error);
2327
2363
  if(!proxy) return NULL;
2328
2364
 
2329
 
  infd_directory_node_link_session(directory, node, proxy);
 
2365
  if(node->shared.note.session == NULL)
 
2366
    infd_directory_node_link_session(directory, node, proxy);
 
2367
 
2330
2368
  g_object_unref(proxy);
2331
2369
 
2332
2370
  return node->shared.note.session;
4815
4853
    error
4816
4854
  );
4817
4855
 
 
4856
  g_object_unref(group);
 
4857
 
4818
4858
  if(node == NULL)
4819
4859
    return FALSE;
4820
4860