More Composer Publishing fixes

This commit is contained in:
cmanske%netscape.com 1998-10-07 00:35:30 +00:00
Родитель bfa38ecb19
Коммит 18ae6aa67b
3 изменённых файлов: 34 добавлений и 59 удалений

Просмотреть файл

@ -578,7 +578,7 @@ class CEditPublishData {
// Characters that are not allowed in the destination URL for publishing.
// RFC 1808 and RFC 2068, we are erring on the safe side and allowing
// some potentially illegal URLs.
#define ED_BAD_PUBLISH_URL_CHARS "# <>\""
#define ED_BAD_PUBLISH_URL_CHARS "%# <>\""
// Return a STATIC string, don't free.
PRIVATE int edt_CheckPublishURL(char *pURL) {
@ -629,7 +629,7 @@ PRIVATE int edt_CheckPublishURL(char *pURL) {
// so supplied URL string may be changed
// MAC AND UNIX -- REMOVE IFDEFs AFTER CHANGING FE CALLS TO USE ppURL
#ifdef XP_WIN
XP_Bool EDT_CheckPublishURL( MWContext *pContext, char **ppURL)
ED_PublishError EDT_CheckPublishURL( MWContext *pContext, char **ppURL)
{
char *pURL = *ppURL;
#else
@ -637,7 +637,7 @@ XP_Bool EDT_CheckPublishURL( MWContext *pContext, char *pURL)
{
#endif
XP_Bool bRetVal = TRUE;
ED_PublishError iRetVal = ED_PUBLISH_OK;
int xpStrId = edt_CheckPublishURL(pURL);
@ -669,10 +669,13 @@ XP_Bool EDT_CheckPublishURL( MWContext *pContext, char *pURL)
return EDT_CheckPublishURL(pContext, pURL);
#endif
}
// Let user edit their mistakes
// We don't know if the error was in location part or filename
else return ED_PUBLISH_ERROR_FILENAME;
}
else if( xpStrId == XP_EDT_PUBLISH_NO_EXTENSION )
{
// Ask user if they want to replace bad chars with '_'
// Ask user if they want to append missing extension: ".html"
if( FE_Confirm(pContext, message) )
{
#ifdef XP_WIN
@ -683,7 +686,8 @@ XP_Bool EDT_CheckPublishURL( MWContext *pContext, char *pURL)
XP_FREEIF(message);
// Prevent infinite loop if we had an allocation error
if( !pNewLocation )
return FALSE;
return ED_PUBLISH_ERROR_FILENAME;
// Check for any other errors
return EDT_CheckPublishURL(pContext, ppURL);
#else
@ -691,13 +695,19 @@ XP_Bool EDT_CheckPublishURL( MWContext *pContext, char *pURL)
return FALSE;
#endif
}
else return ED_PUBLISH_ERROR_FILENAME;
}
else
{
// Report the error, but give the user the option of trying to publish anyway.
StrAllocCat(message,"\n\n");
StrAllocCat(message,XP_GetString(XP_EDT_PUBLISH_ERROR_BODY));
bRetVal = FE_Confirm(pContext,message);
if( !FE_Confirm(pContext,message) )
{
// The only other filename-specific error is no filename at all
iRetVal = (xpStrId == XP_EDT_PUBLISH_NO_FILE) ?
ED_PUBLISH_ERROR_FILENAME : ED_PUBLISH_ERROR_LOCATION;
}
}
XP_FREEIF(message);
}
@ -706,7 +716,7 @@ XP_Bool EDT_CheckPublishURL( MWContext *pContext, char *pURL)
}
}
return bRetVal;
return iRetVal;
}
ED_FileError EDT_PublishFile( MWContext * pContext,

Просмотреть файл

@ -8130,41 +8130,9 @@ char* CEditBuffer::GetAllDocumentTargetsInFile(char *pHref)
// The UNIX/MAC code is XP and should really be used for
// windows also. We're just scared to change it this late
// in the cycle. Bug 50888
#ifdef XP_WIN
// First check if URL is a local file that exists
XP_StatStruct stat;
XP_Bool bFreeFilename = FALSE;
// cmanske: 10/6/98 Tested the XP code and it seems to work fine in Windows
#if defined(XP_MAC) || defined(XP_UNIX) || defined(XP_OS2)
if ( -1 != XP_Stat(pHref, &stat, xpURL) &&
stat.st_mode & S_IFREG ) {
#else
if ( -1 != XP_Stat(pHref, &stat, xpURL) &&
stat.st_mode & _S_IFREG ) {
#endif
// We can use unprocessed URL,
// and we don't need to free it
pFilename = pHref;
}
else {
// We probably have a URL,
// get absolute URL path then convert to local format
char *pAbsolute = NET_MakeAbsoluteURL( pCurrentURL, pHref );
if( !pAbsolute ||
!XP_ConvertUrlToLocalFile(pAbsolute, &pFilename) ){
if( pFilename ) XP_FREE(pFilename);
if( pAbsolute ) XP_FREE(pAbsolute);
return NULL;
}
XP_FREE(pAbsolute);
// We need to free the filename made for us
bFreeFilename = TRUE;
}
#else
// pFilename is in xpURL format.
// First check if URL is a local file that exists
char *pURL = XP_PlatformFileToURL(pHref);
if (pURL && XP_ConvertUrlToLocalFile(pURL,NULL)) {
@ -8189,20 +8157,11 @@ char* CEditBuffer::GetAllDocumentTargetsInFile(char *pHref)
if (!pFilename) {
return NULL;
}
#endif
// Open local file
XP_File file = XP_FileOpen( pFilename, xpURL, XP_FILE_READ );
if( !file ) {
// Same story as above. Should use the non-windows version.
#ifdef XP_WIN
if( pFilename && bFreeFilename ){
XP_FREE(pFilename);
}
#else
XP_FREEIF(pFilename);
#endif
return NULL;
}
@ -8292,15 +8251,7 @@ FIND_TAG:
}
}
XP_FileClose(file);
// Same story as above. Should use the non-windows version.
#ifdef XP_WIN
if( pFilename && bFreeFilename ){
XP_FREE(pFilename);
}
#else
XP_FREEIF(pFilename);
#endif
pBuf[iCur] = 0;

Просмотреть файл

@ -8584,8 +8584,22 @@ void CEditTextElement::PartialStreamOut( IStreamOut *pOut, CEditSelection& selec
pOut->WriteInt( m_color.GetAsLong() );
if( m_tf & TF_HREF ){
pOut->WriteZString( m_href->hrefStr );
if( m_tf & TF_HREF )
{
// Must make URLs absolute when copying
CEditBuffer *pBuffer = GetEditBuffer();
char *pAbsolute = NULL;
if( pBuffer )
pAbsolute = NET_MakeAbsoluteURL(LO_GetBaseURL(pBuffer->m_pContext), m_href->hrefStr);
if( pAbsolute )
{
pOut->WriteZString( pAbsolute );
XP_FREE(pAbsolute);
}
else
pOut->WriteZString( m_href->hrefStr );
pOut->WriteZString( m_href->pExtra );
}