+2005-03-05 Darin Adler <darin@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/4025918> images copied from Safari with relative src URLs aren't pasted into Mail messages (KURL resolves base URLs incorrectly)
+
+ * kwq/KWQKURL.mm: (KURL::KURL): Add a slash at the start of the path if a relative part is adding
+ a path onto a URL that has "pre-path" bits like host name, but no path yet. This doesn't come up
+ for http because in that case we add a trailing "/" as part of canonicalization.
+
2005-03-04 John Sullivan <sullivan@apple.com>
Reviewed by Kevin.
char staticBuffer[2048];
char *buffer;
- size_t bufferLength = base.pathEndPos + strlen(str) + 1;
+ // Base part plus relative part plus one possible slash added in between plus terminating \0 byte.
+ size_t bufferLength = base.pathEndPos + 1 + strlen(str) + 1;
if (bufferLength > sizeof(staticBuffer)) {
buffer = (char *)malloc(bufferLength);
baseStringEnd--;
}
- bufferPos += copyPathRemovingDots(bufferPos, baseStringStart, 0, baseStringEnd - baseStringStart);
+ if (baseStringEnd == baseStringStart) {
+ // no path in base, add a path separator if necessary
+ if (base.schemeEndPos + 1 != base.pathEndPos && *str != '\0' && *str != '?' && *str != '#') {
+ *bufferPos++ = '/';
+ }
+ } else {
+ bufferPos += copyPathRemovingDots(bufferPos, baseStringStart, 0, baseStringEnd - baseStringStart);
+ }
const char *relStringStart = str;
const char *relStringPos = relStringStart;