summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sb@openoffice.org>2002-09-06 12:31:02 +0000
committerStephan Bergmann <sb@openoffice.org>2002-09-06 12:31:02 +0000
commita6b00d396a8d113f1cb0a7ea7654c9d7dc75042d (patch)
tree2c4c2fb3b873c4103a2ea6a9dd5fa8df72590638 /tools
parent992541b6395bec8b22bba942d42ead6e821cc0ff (diff)
#102967# When smart parsing, accept things like file://d:\dir1\file1 as file URLs (generated by MS IE).
Diffstat (limited to 'tools')
-rw-r--r--tools/source/fsys/urlobj.cxx35
-rw-r--r--tools/workben/urltest.cxx41
2 files changed, 63 insertions, 13 deletions
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 37fbdead104d..987f535d6890 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urlobj.cxx,v $
*
- * $Revision: 1.32 $
+ * $Revision: 1.33 $
*
- * last change: $Author: sb $ $Date: 2002-08-28 14:24:15 $
+ * last change: $Author: sb $ $Date: 2002-09-06 13:29:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1014,7 +1014,19 @@ bool INetURLObject::setAbsURIRef(UniString const & rTheAbsURIRef,
}
}
- // 2nd Production (misscounted slashes):
+ // 2nd Production (MS IE generated 1; FSYS_DOS only):
+ // "//" ALPHA ":" ["/" *path] ["#" *UCS4]
+ // becomes
+ // "file:///" ALPHA ":" ["/" *path] ["#" *UCS4]
+ // replacing "\" by "/" within <*path>
+ //
+ // 3rd Production (MS IE generated 2; FSYS_DOS only):
+ // "//" ALPHA ":" ["\" *path] ["#" *UCS4]
+ // becomes
+ // "file:///" ALPHA ":" ["/" *path] ["#" *UCS4]
+ // replacing "\" by "/" within <*path>
+ //
+ // 4th Production (misscounted slashes):
// "//" *path ["#" *UCS4]
// becomes
// "file:///" *path ["#" *UCS4]
@@ -1024,10 +1036,17 @@ bool INetURLObject::setAbsURIRef(UniString const & rTheAbsURIRef,
AppendAscii(RTL_CONSTASCII_STRINGPARAM("//"));
pPos += 2;
bSkippedInitialSlash = true;
+ if ((eStyle & FSYS_DOS) != 0
+ && pEnd - pPos >= 2
+ && INetMIME::isAlpha(pPos[0])
+ && pPos[1] == ':'
+ && (pEnd - pPos == 2
+ || pPos[2] == '/' || pPos[2] == '\\'))
+ nAltSegmentDelimiter = '\\';
break;
}
- // 3rd Production (Unix):
+ // 5th Production (Unix):
// "/" *path ["#" *UCS4]
// becomes
// "file:///" *path ["#" *UCS4]
@@ -1038,7 +1057,7 @@ bool INetURLObject::setAbsURIRef(UniString const & rTheAbsURIRef,
break;
}
- // 4th Production (UNC; FSYS_DOS only):
+ // 6th Production (UNC; FSYS_DOS only):
// "\\" domain ["\" *path] ["#" *UCS4]
// becomes
// "file://" domain "/" *path ["#" *UCS4]
@@ -1063,13 +1082,13 @@ bool INetURLObject::setAbsURIRef(UniString const & rTheAbsURIRef,
}
}
- // 5th Production (Unix-like DOS; FSYS_DOS only):
+ // 7th Production (Unix-like DOS; FSYS_DOS only):
// ALPHA ":" ["/" *path] ["#" *UCS4]
// becomes
// "file:///" ALPHA ":" ["/" *path] ["#" *UCS4]
// replacing "\" by "/" within <*path>
//
- // 6th Production (DOS; FSYS_DOS only):
+ // 8th Production (DOS; FSYS_DOS only):
// ALPHA ":" ["\" *path] ["#" *UCS4]
// becomes
// "file:///" ALPHA ":" ["/" *path] ["#" *UCS4]
@@ -1089,7 +1108,7 @@ bool INetURLObject::setAbsURIRef(UniString const & rTheAbsURIRef,
break;
}
- // 7th Production (any):
+ // 9th Production (any):
// *path ["#" *UCS4]
// becomes
// "file:///" *path ["#" *UCS4]
diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx
index 4889771a2b92..22db96a517a8 100644
--- a/tools/workben/urltest.cxx
+++ b/tools/workben/urltest.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urltest.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: sb $ $Date: 2002-08-28 14:44:03 $
+ * last change: $Author: sb $ $Date: 2002-09-06 13:31:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1139,12 +1139,43 @@ main()
{ "file://xxx.yyy-zzz/abc", "file://xxx.yyy-zzz/abc" },
{ "file://xxx_yyy/abc", "file://xxx_yyy/abc" },
{ "file://!%23$%&'()-.@^_{}~/abc",
- "file://!%23$%25&'()-.@%5E_%7B%7D~/abc" } };
+ "file://!%23$%25&'()-.@%5E_%7B%7D~/abc" },
+ { "file://d:\\dir1\\file1", 0 } };
for (int i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
{
INetURLObject aUrl(aTest[i].m_pInput);
- if (aUrl.HasError() != (aTest[i].m_pOutput == 0)
- || aUrl.GetMainURL().CompareToAscii(aTest[i].m_pOutput) != 0)
+ if (aTest[i].m_pOutput == 0
+ ? !aUrl.HasError()
+ : (aUrl.HasError()
+ || (aUrl.GetMainURL().CompareToAscii(aTest[i].m_pOutput)
+ != 0)))
+ printf("BAD %s -> %s != %s\n",
+ aTest[i].m_pInput,
+ aUrl.HasError() ? "<none>"
+ : ByteString(aUrl.GetMainURL(),
+ RTL_TEXTENCODING_ASCII_US).GetBuffer(),
+ aTest[i].m_pOutput == 0 ? "<none>" : aTest[i].m_pOutput);
+ }
+ }
+
+ if (true)
+ {
+ struct Test
+ {
+ char const * m_pInput;
+ char const * m_pOutput;
+ };
+ static Test const aTest[]
+ = { { "file://d:\\dir1\\file1", "file:///d:/dir1/file1" } };
+ for (int i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+ {
+ INetURLObject aUrl(String(aTest[i].m_pInput, RTL_TEXTENCODING_UTF8),
+ INET_PROT_HTTP);
+ if (aTest[i].m_pOutput == 0
+ ? !aUrl.HasError()
+ : (aUrl.HasError()
+ || (aUrl.GetMainURL().CompareToAscii(aTest[i].m_pOutput)
+ != 0)))
printf("BAD %s -> %s != %s\n",
aTest[i].m_pInput,
aUrl.HasError() ? "<none>"