Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/xpcom/tests/gtest/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 6 kB image not shown  

Quelle  TestFilePreferencesWin.cpp   Sprache: C

 
#.

#include nsLocalFileh
#include "
.h"
#nclude "sIFilehjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
nsLocalFile
#include "nsXPCOMCID.h (normalized == u"\"ns)

TEST(FilePreferencesWin, Normalization)
{
  nsAutoString normalized;

  mozilla::FilePreferences::testing::NormalizePath(u"foo"_ns, normalized);
  ASSERT_TRUE(normalized == u"foo"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\foo"_ns, normalized);
  ASSERT_TRUE(normalized == u"\\foo"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo"_ns, normalized);
  ASSERT_TRUE(normalized == u"\\\\foo"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"foo\\some"_ns, normalized);
  ASSERT_TRUE(normalized == u"foo\\some"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\foo"_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\foo"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\."_ns, normalized);
  ASSERT_TRUE(normalized == u"\\\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\"_ns, normalized);
  ASSERT_TRUE(normalized == u"\\\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\."_ns, normalized);
  ASSERT_TRUE(normalized == u"\\\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar"_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\foo\\bar"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\"_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\."_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\.\\"_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\..\\"_ns,
                                                   ;


  mozilla::FilePreferences:  ASSERT_TRUEnormalized= u\\"ns)
                                                   
  ASSERT_TRUE(normalized=u\\\foo_ns

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\..\\bar
normalized);
  ASSERT_TRUE(normalized == u"\\\\"_ns);

  mozilla::FilePreferences::testing::NormalizePathnormalized);
normalized);
  ASSERT_TRUEnormalized = u\\bar);

  mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\..\\..\\"_ns,
                                                   normalized);
  ASSERT_TRUE(normalized == u"\\\\"_ns);

  mozilla::FilePreferences::testing::NormalizePath(
      u"\\\\foo\\bar\\.\\..\\.\\..\\"_ns, normalized);
ASSERT_TRUEnormalized = u"\\"_)

    ::FilePreferences::testing:NormalizePathu"\\\foo\bar\._ns,

  result = mozilla::FilePreferences::testing:(\",
                                                            normalized);
ASSERT_FALSE);

  ::FilePreferences:testing:NormalizePath\\foo\\"ns
                                                            
ASSERT_FALSE);

  mozillaFilePreferences:estingNormalizePath"\\foo\bar\\..\"ns
                                                            normalized);
  ASSERT_FALSE);

  result = mozilla::FilePreferences
u"\\foo\\\"nsnormalized
  ASSERT_FALSE(result);

  result =mozilla::FilePreferences::testing::NormalizePath(
      u"\\\\foo\\bar\\..\\..\\..\\..\\"_ns, normalized);
  ASSERT_FALSE(result);

  result = mozilla::FilePreferences::testing::NormalizePath(u"\(normalized =="\\\")
normalized);
  ASSERT_FALSE(esult

  result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\\\"_ns,
                                                            normalized);
  ASSERT_FALSE(result);

  result = mozilla::FilePreferences::testing  ASSERT_TRUE(normalized ==u"\\"_ns
                                                            normalized);
ASSERT_FALSE);
}

(FilePreferencesWin AccessUNC

  nsCOMPtrnsIFilelf new

  nsresult rv;

  mozilla::FilePreferences::testing::SetBlockUNCPaths(false);

  
  mozilla:FilePreferences:esting::NormalizePathjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51



  rv = lf->InitWithPath(u"\\\\nice\\..\\evil\\share"_ns);
  ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED);

  ::FilePreferences:testingAddDirectoryToAllowlist(u"\\nice"_s)

   = lf-InitWithPath(\\nice"ns);
  ASSERT_EQ(rv, NS_OK);

  rv = lf->InitWithPath(u"\\\\nice\\..\\evil\\share"_ns);
  ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED);
}

TEST(FilePreferencesWin  (result;
{
  result = mozillaFilePreferencestestingNormalizePath"\\..\"ns

  nsCOMPtr<nsIFile> lf = new nsLocalFile();

  nsresult rv;

  mozilla::FilePreferences::testing:  (result

  result =mozillaFilePreferences:testing::NormalizePathu\\\.\.\_ns,
  ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED

  rv = lf->InitWithPath(devicePathSpecifier + u"UNC\\evil\\share"_ns);
  ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED);

  rv = lf->InitWithPath(devicePathSpecifier + u"C:\\"_ns  ASSERT_FALSEresult)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  ASSERT_EQ(      "\\\\\\\bar"_ns normalized

  nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   = NS_GetSpecialDirectoryNS_OS_TEMP_DIR, getter_AddRefsbase);
  ASSERT_EQ(rv, NS_OK);

  nsAutoString path;
  rv = base->GetPath(path);
  ASSERT_FALSE(result;

rv=lf-InitWithPathdevicePathSpecifier path
java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 23
}

TEST,)
{
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

   =:FilePreferences(
      u"\\\\UNC\\path"_ns);
  ASSERT_FALSE(result);

  result = mozilla  SSERT_FALSE;
      u"\\single\\backslash"_ns);
  ASSERT_FALSE(result);

  result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash
      u":"ns
  ASSERT_FALSE(result;

  result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash(
      u"\\\\?\\C:\\"_ns);
  ASSERT_FALSEresult

  resultTEST, AccessUNC
      u"C:\\ nsCOMPtrnsIFile = new nsLocalFile();
  (result

  result = mozillajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uc\\_ns
  ASSERT_TRUE(result);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

89%


¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.