void lo_FormatJavaObject(MWContext *context, lo_DocState *state, PA_Tag *tag, LO_JavaAppStruct *java_app) { PA_Block buff; buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { char* str; PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "java:", 5) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVA; else if (XP_STRNCASECMP(str, "javaprogram:", 12) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM; else if (XP_STRNCASECMP(str, "javabean:", 8) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVABEAN; PA_UNLOCK(buff); XP_FREE(buff); } if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM) { java_app->ele_attrmask |= LO_ELE_HIDDEN; } else { /* Get the HIDDEN parameter */ java_app->ele_attrmask = 0; buff = lo_FetchParamValue(context, tag, PARAM_HIDDEN); if (buff != NULL) { Bool hidden = TRUE; char* str; PA_LOCK(str, char *, buff); if (pa_TagEqual("no", str)) { hidden = FALSE; } else if (pa_TagEqual("false", str)) { hidden = FALSE; } else if (pa_TagEqual("off", str)) { hidden = FALSE; } PA_UNLOCK(buff); PA_FREE(buff); if (hidden != FALSE) { java_app->ele_attrmask |= LO_ELE_HIDDEN; } } } /* Finish formatting the object */ lo_FormatJavaAppInternal(context, state, tag, java_app); }
static int IsWebJumper(const char *url) { const char *filename=url; // make sure it's a file if (XP_STRNCASECMP(url,"file:",5)==0) filename=url+5; if (strlen(filename)==0 || filename[0]!='/') return FALSE; // check for SGI WebJumper FILE *fp; int retval=FALSE; if (fp=fopen(filename,"r")) { const int MAX_LENGTH=4000; char line[MAX_LENGTH+1]; line[MAX_LENGTH]='\0'; line[0]='\0'; // ensure string will be null-terminated fgets(line,MAX_LENGTH,fp); if (XFE_WebJumperDesktopType::isDesktopType(line)) { retval=TRUE; } fclose(fp); } return retval; }
// create short icon label from full path/url char *XFE_ComposeAttachFolderView::parseItemLabel(const char *url) { // (alastair) code taken from libmsg/msgsend.cpp - be nice just to call into libmsg // modified slightly to avoid bug of trailing / generating empty name // modified to return truncated label for mail/news URL's if (!url || strlen(url)==0) return XP_STRDUP("(null)"); char *s; char *s2; char *s3; /* If we know the URL doesn't have a sensible file name in it, don't bother emitting a content-disposition. */ if (!strncasecomp (url, "news:", 5)) return XP_STRDUP("news:"); if (!strncasecomp (url, "snews:", 6)) return XP_STRDUP("snews:"); if (!strncasecomp (url, "mailbox:", 8)) return XP_STRDUP("mailbox:"); char *tmpLabel = XP_STRDUP(url); s=tmpLabel; /* remove trailing / or \ */ int len=strlen(s); if (s[len-1]=='/' || s[len-1]=='\\') s[len-1]='\0'; s2 = XP_STRCHR (s, ':'); if (s2) s = s2 + 1; /* Take the part of the file name after the last / or \ */ s2 = XP_STRRCHR (s, '/'); if (s2) s = s2+1; s2 = XP_STRRCHR (s, '\\'); if (s2) s = s2+1; /* if it's a non-file url, strip off any named anchors or search data */ if (XP_STRNCASECMP(url,"file:",5)!=0 && url[0]!='/') { /* Now trim off any named anchors or search data. */ s3 = XP_STRCHR (s, '?'); if (s3) *s3 = 0; s3 = XP_STRCHR (s, '#'); if (s3) *s3 = 0; } /* Now lose the %XX crap. */ NET_UnEscape (s); char *retLabel=XP_STRDUP(s); XP_FREE(tmpLabel); return retLabel; }
static XP_Bool vr_CompareDirs( char *dir1, char *dir2 ) { int len1,len2; XP_ASSERT( dir1 && dir2 ); if (!dir1 || !dir2) return FALSE; len1 = XP_STRLEN( dir1 ); len2 = XP_STRLEN( dir2 ); if ( dir1[len1-1] == VR_FILE_SEP ) len1--; if ( dir2[len2-1] == VR_FILE_SEP ) len2--; if ( len1 != len2 ) return FALSE; #if defined(XP_UNIX) && !defined(XP_MACOSX) return ( XP_STRNCMP(dir1, dir2, len1) == 0 ); #else return ( XP_STRNCASECMP(dir1, dir2, len1) == 0 ); #endif }
// nyi - extract nice file name from title or url char *XFE_URLDesktopType::getFilename(int pos) { if (pos<0 || pos>=_numItems || _url[pos]==NULL) return XP_STRDUP("unknown"); // (alastair) code taken from libmsg/msgsend.cpp - be nice just to call into libmsg // modified slightly to avoid bug of trailing / generating empty name // modified to return truncated label for mail/news URL's const char *url=_url[pos]; if (!url || strlen(url)==0) return XP_STRDUP("(null)"); char *s; char *s2; char *s3; /* If we know the URL doesn't have a sensible file name in it, don't bother emitting a content-disposition. */ if (!XP_STRNCASECMP(url, "news:", 5)) return XP_STRDUP("news:"); if (!XP_STRNCASECMP(url, "snews:", 6)) return XP_STRDUP("snews:"); if (!XP_STRNCASECMP(url, "mailbox:", 8)) return XP_STRDUP("mailbox:"); char *tmpLabel = XP_STRDUP(url); s=tmpLabel; /* remove trailing / or \ */ int len=strlen(s); if (s[len-1]=='/' || s[len-1]=='\\') s[len-1]='\0'; s2 = XP_STRCHR (s, ':'); if (s2) s = s2 + 1; /* Take the part of the file name after the last / or \ */ if (s2 = XP_STRRCHR (s, '/')) s = s2+1; else if (s2 = XP_STRRCHR (s, '\\')) s = s2+1; /* if it's a non-file url do some additional massaging */ if (XP_STRNCASECMP(url,"file:",5)!=0 && url[0]!='/') { /* Trim off any named anchors or search data. */ s3 = XP_STRCHR (s, '?'); if (s3) *s3 = 0; s3 = XP_STRCHR (s, '#'); if (s3) *s3 = 0; /* Check for redundant document name. * Use previous URL component to provide more meaningful file name. */ if (s2 && XP_STRCASECMP(s,"index.html")==0 || XP_STRCASECMP(s,"index.htm")==0 || XP_STRCASECMP(s,"index.cgi")==0 || XP_STRCASECMP(s,"index.shtml")==0 || XP_STRCASECMP(s,"home.html")==0 || XP_STRCASECMP(s,"home.htm")==0 || XP_STRCASECMP(s,"home.cgi")==0 || XP_STRCASECMP(s,"home.shtml")==0) { /* Trim redundant component and try again */ *s2='\0'; s=tmpLabel; /* Redo: Take the part of the file name after the last / or \ */ if (s2 = XP_STRRCHR (s, '/')) s = s2+1; else if (s2 = XP_STRRCHR (s, '\\')) s = s2+1; } } /* Now lose the %XX crap. */ NET_UnEscape (s); char *retLabel=XP_STRDUP(s); XP_FREE(tmpLabel); return retLabel; }
void lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) { lo_TopState* top_state = state->top_state; lo_ObjectStack* top; LO_ObjectStruct* object; PA_Block buff; int16 type = LO_NONE; char* str; #ifdef ANTHRAX XP_Bool javaMimetypeHandler = FALSE; char* appletName; NET_cinfo* fileInfo; #endif /* ANTHRAX */ /* * Make a new default object. Passing LO_OBJECT will create an * LO_Element, which being a union of all other layout element types * is guaranteed to be big enough to transmogrify into one of these * specific types later if necessary. */ object = (LO_ObjectStruct*) lo_NewElement(context, state, LO_OBJECT, NULL, 0); if (object == NULL) { state->top_state->out_of_memory = TRUE; return; } top = top_state->object_stack; top->object = object; /* * Set up default fields for this object that are common * to all possible object types. */ object->lo_element.type = LO_NONE; object->lo_element.lo_any.ele_id = NEXT_ELEMENT; object->lo_element.lo_any.x = state->x; object->lo_element.lo_any.x_offset = 0; object->lo_element.lo_any.y = state->y; object->lo_element.lo_any.y_offset = 0; object->lo_element.lo_any.width = 0; object->lo_element.lo_any.height = 0; object->lo_element.lo_any.next = NULL; object->lo_element.lo_any.prev = NULL; /* * Now attempt to figure out what type of object we have. * If the type can be determined here, great; otherwise * we have to block until the type can be determined by * reading in additional data. * * Initially the type of the object is LO_NONE. When * we figure out enough to know the type, we set it to * LO_EMBED, LO_JAVA, or LO_IMAGE. If the type had * already been changed to a different incompatible type, * then the tag is malformed and we should ignore it, so * set the type to LO_UNKNOWN. */ #if 0 /* * Check the "codetype" attribute, which optionally determines * the MIME type of the object code itself (as opposed to its * data). The only code type we know about right now is * application/java-vm for Java applets. */ buff = lo_FetchParamValue(context, tag, PARAM_CODETYPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (pa_TagEqual(APPLICATION_JAVAVM, str)) { /* It's a Java applet */ if (type == LO_NONE) type = LO_JAVA; else if (type != LO_JAVA) type = LO_UNKNOWN; } else if (pa_TagEqual(APPLICATION_OLEOBJECT, str) || pa_TagEqual(APPLICATION_OLEOBJECT2, str)) { /* It's an OLE object */ if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } PA_UNLOCK(buff); XP_FREE(buff); } #endif /* * Check the "classid" attribute, which optionally determines * the specific implementation of the object. The classid * could be a normal URL, in which case we have to retrieve * that URL and match it against a known code type (see above). * There are also two "magic" URL types supported for classid: * "clsid:", which indicates a COM 376-hex-digit class ID, * and "java:", which indicates a specific java class to run. * Note that the "java:" URL is different from the APPLET * "code" attribute: the "java:" URL specifies a particular * method (e.g. "java:program.run"), while the APPLET CODE * attribute specifies an applet subclass (e.g. "MyApplet.class"). * * Further notes about "java:" * We are adding two related "magic" protocol selectors to * augment "java:". These are "javaprogram:" and "javabean:". * They are used with embedded applications and application * objects. "javaprogram:" identifies an object as being a * subclass of netscape.application.Application, and is used * to start an instance of such application. "javabean:" is * used to add an embedded object to an application. */ buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "clsid:", 6) == 0) { /* * It's a COM class ID, so make sure we have an * appropriate plug-in to handle ActiveX controls. */ if (NPL_FindPluginEnabledForType(APPLICATION_OLEOBJECT) != NULL) { if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } } else if ( (XP_STRNCASECMP(str, "java:", 5) == 0) || (XP_STRNCASECMP(str, "javaprogram:", 12) == 0) || (XP_STRNCASECMP(str, "javabean:", 9) == 0) ) { /* It's a Java class */ if (type == LO_NONE) type = LO_JAVA; else if (type != LO_JAVA) type = LO_UNKNOWN; } else { /* * Must be a URL to the code; we'll need to fetch it to * determine the type. bing: How should we do this? */ } PA_UNLOCK(buff); XP_FREE(buff); } /* * Check the "type" attribute, which optionally determines * the type of the data for the object. The data type * can be used to infer the object implementation type if * the implementation hasn't been specified via "classid" * or "codetype" (see above). The two kinds of objects * we currently support with typed data are plug-ins and * images; for plug-ins we can ask libplug if the type is * currently handled by a plug-in; for images we just check * against a hard-coded list of image types we natively * support (yuck). */ buff = lo_FetchParamValue(context, tag, PARAM_TYPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (NPL_FindPluginEnabledForType(str) != NULL) { /* It's a plug-in */ if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } /* Adding a check for applets that handle mimetypes. The pref is stored based on the particular mimetype. We do a lookup and if there is an association, the name of the applet is placed into "appletName". NOTE: PREF_CopyCharPref() allocates memory for appletName and we must free it. 9.23.97 amusil */ #ifdef ANTHRAX if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) { /* Set the type */ type = LO_JAVA; /* set the CLASSID to whatever was put into "appletName" */ lo_SetClassID(tag, appletName); /* set this so that we know later to translate the DATA/SRC param to a Java arg */ javaMimetypeHandler = TRUE; XP_FREE(appletName); } #endif /* ANTHRAX */ #if 0 else if (XP_STRNCASECMP(str, "image/", 6) == 0) { if (XP_STRCASECMP(str, IMAGE_GIF) || XP_STRCASECMP(str, IMAGE_JPG) || XP_STRCASECMP(str, IMAGE_PJPG) || XP_STRCASECMP(str, IMAGE_XBM) || XP_STRCASECMP(str, IMAGE_XBM2) || XP_STRCASECMP(str, IMAGE_XBM3)) { /* It's an image */ if (type == LO_NONE) type = LO_IMAGE; else if (type != LO_IMAGE) type = LO_UNKNOWN; } } #endif /* if 0 */ #ifdef SHACK if (XP_STRNCASECMP(str, "builtin", 7) == 0) { if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } #endif /* SHACK */ PA_UNLOCK(buff); XP_FREE(buff); } #ifdef ANTHRAX else /* we didn't find a TYPE param, so check the filename to get the type - amusil */ { buff = lo_FetchParamValue(context, tag, PARAM_SRC); /* if no src, check if there's a DATA param */ if(buff == NULL) buff = lo_FetchParamValue(context, tag, PARAM_DATA); /* extract the mimetype info */ PA_LOCK(str, char *, buff); fileInfo = NET_cinfo_find_type(str); str = fileInfo->type; if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) { /* Set the type */ type = LO_JAVA; /* set the CLASSID to whatever was put into "appletName" */ lo_SetClassID(tag, appletName); /* set this so that we know later to translate the DATA/SRC param to a Java arg */ javaMimetypeHandler = TRUE; XP_FREE(appletName); /* do we need to free this regardless? */ } if(buff) XP_FREE(buff); } #endif /* ANTRHAX */ if (type == LO_EMBED) { object->lo_element.type = LO_EMBED; } #ifdef JAVA else if (type == LO_JAVA) { if (LJ_GetJavaEnabled() != FALSE) { /* * Close out the current applet if necessary * (people tend to forget "</APPLET>"). */ if (state->current_java != NULL) lo_CloseJavaApp(context, state, state->current_java); object->lo_element.type = LO_JAVA; lo_FormatJavaObject(context, state, tag, (LO_JavaAppStruct*) object); /* If we determined previously that this is an applet to mimetype association, we must set up the SRC or DATA as an arg for the applet. 9.8.97 amusil */ #ifdef ANTHRAX if(javaMimetypeHandler) lo_SetJavaArgs((char*)tag->data, state->current_java); #endif /* ANTHRAX */ } } #endif /* JAVA */ #if 0 else if (type == LO_IMAGE) { object->type = LO_IMAGE; lo_FormatImageObject(context, state, tag, (LO_ImageStruct*) object); } #endif /* if 0 */ else { /* * Check for a "data" attribute; if it exists, we can get * the URL later to see what the type of the object should be. */ buff = lo_FetchParamValue(context, tag, PARAM_DATA); if (buff != NULL) { PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "data:", 5) == 0) { /* bing: deal with magic data URLs here */ PA_UNLOCK(buff); XP_FREE(buff); } else { /* * Block layout until we can read the PARAM tags * and closing </OBJECT> tag, go get the data URL, * and determine its type. At that point (in * either LO_NewObjectStream, or lo_ObjectURLExit), * we know the object type and can unblock. */ top->data_url = str; state->top_state->layout_blocking_element = (LO_Element*) object; PA_UNLOCK(buff); /* Don't free buff; we stored it in the object stack */ } } else { /* * Otherwise we just don't know what to do with this! */ object->lo_element.type = LO_UNKNOWN; } } }
const char * lm_CheckURL(JSContext *cx, const char *url_string, JSBool checkFile) { char *protocol, *absolute; JSObject *obj; MochaDecoder *decoder; protocol = NET_ParseURL(url_string, GET_PROTOCOL_PART); if (!protocol || *protocol == '\0') { lo_TopState *top_state; obj = JS_GetGlobalObject(cx); decoder = JS_GetPrivate(cx, obj); LO_LockLayout(); top_state = lo_GetMochaTopState(decoder->window_context); if (top_state && top_state->base_url) { absolute = NET_MakeAbsoluteURL(top_state->base_url, (char *)url_string); /*XXX*/ /* * Temporarily unlock layout so that we don't hold the lock * across a call (lm_CheckPermissions) that may result in * synchronous event handling. */ LO_UnlockLayout(); if (!lm_CheckPermissions(cx, obj, JSTARGET_UNIVERSAL_BROWSER_READ)) { /* Don't leak information about the url of this page. */ XP_FREEIF(absolute); return NULL; } LO_LockLayout(); } else { absolute = NULL; } if (absolute) { if (protocol) XP_FREE(protocol); protocol = NET_ParseURL(absolute, GET_PROTOCOL_PART); } LO_UnlockLayout(); } else { absolute = JS_strdup(cx, url_string); if (!absolute) { XP_FREE(protocol); return NULL; } decoder = NULL; } if (absolute) { /* Make sure it's a safe URL type. */ switch (NET_URL_Type(protocol)) { case FILE_TYPE_URL: if (checkFile) { const char *subjectOrigin = lm_GetSubjectOriginURL(cx); if (subjectOrigin == NULL) { XP_FREE(protocol); return NULL; } if (NET_URL_Type(subjectOrigin) != FILE_TYPE_URL && !lm_CanAccessTarget(cx, JSTARGET_UNIVERSAL_FILE_READ)) { XP_FREE(absolute); absolute = NULL; } } break; case FTP_TYPE_URL: case GOPHER_TYPE_URL: case HTTP_TYPE_URL: case MAILTO_TYPE_URL: case NEWS_TYPE_URL: case RLOGIN_TYPE_URL: case TELNET_TYPE_URL: case TN3270_TYPE_URL: case WAIS_TYPE_URL: case SECURE_HTTP_TYPE_URL: case URN_TYPE_URL: case NFS_TYPE_URL: case MOCHA_TYPE_URL: case VIEW_SOURCE_TYPE_URL: case NETHELP_TYPE_URL: case WYSIWYG_TYPE_URL: case LDAP_TYPE_URL: #ifdef JAVA case MARIMBA_TYPE_URL: #endif /* These are "safe". */ break; case ABOUT_TYPE_URL: if (XP_STRCASECMP(absolute, "about:blank") == 0) break; if (XP_STRNCASECMP(absolute, "about:pics", 10) == 0) break; /* these are OK if we are signed */ if (lm_CanAccessTarget(cx, JSTARGET_UNIVERSAL_BROWSER_READ)) break; /* FALL THROUGH */ default: /* All others are naughty. */ XP_FREE(absolute); absolute = NULL; break; } } if (!absolute) { JS_ReportError(cx, "illegal URL method '%s'", protocol && *protocol ? protocol : url_string); } if (protocol) XP_FREE(protocol); return absolute; }
PRIVATE int net_ColorHTMLWrite (NET_StreamClass *stream, CONST char *s, int32 l) { int32 i; int32 last_output_point; char *new_markup=0; char *tmp_markup=0; char tiny_buf[4]; CONST char *cp; int status; DataObject *obj=stream->data_object; last_output_point = 0; for(i = 0, cp = s; i < l; i++, cp++) { switch(obj->state) { case IN_CONTENT: /* do nothing until you find a '<' "<!--" or '&' */ if(*cp == '<') { /* XXX we can miss a comment spanning a block boundary */ if(i+4 <= l && !XP_STRNCMP(cp, "<!--", 4)) { StrAllocCopy(new_markup, BEGIN_COMMENT_MARKUP); StrAllocCat(new_markup, "<"); obj->state = IN_COMMENT; } else { new_markup = net_BeginColorHTMLTag(obj); } } else if(*cp == '&') { StrAllocCopy(new_markup, BEGIN_AMPERSAND_THINGY_MARKUP); StrAllocCat(new_markup, "&"); obj->state = IN_AMPERSAND_THINGY; } break; case IN_SCRIPT: /* do nothing until you find '</SCRIPT>' */ if(*cp == '<') { /* XXX we can miss a </SCRIPT> spanning a block boundary */ if(i+8 <= l && !XP_STRNCASECMP(cp, "</SCRIPT", 8)) { new_markup = net_BeginColorHTMLTag(obj); } } break; case ABOUT_TO_BEGIN_TAG: /* we have seen the first '<' * once we see a non-whitespace character * we will be in the tag identifier */ if(*cp == '>') { StrAllocCopy(new_markup, END_TAG_NAME_MARKUP); tmp_markup = net_EndColorHTMLTag(obj); StrAllocCat(new_markup, tmp_markup); FREE_AND_CLEAR(tmp_markup); } else if(!XP_IS_SPACE(*cp)) { obj->state = IN_BEGIN_TAG; obj->tag_index = 0; obj->tag[obj->tag_index++] = *cp; if(*cp == '<') StrAllocCopy(new_markup, "<"); } break; case IN_BEGIN_TAG: /* go to the IN_TAG state when we see * the first whitespace */ if(XP_IS_SPACE(*cp)) { StrAllocCopy(new_markup, END_TAG_NAME_MARKUP); XP_SPRINTF(tiny_buf, "%c", *cp); StrAllocCat(new_markup, tiny_buf); obj->state = IN_TAG; obj->tag[obj->tag_index] = '\0'; obj->tag_type = pa_tokenize_tag(obj->tag); } else if(*cp == '>') { StrAllocCopy(new_markup, END_TAG_NAME_MARKUP); tmp_markup = net_EndColorHTMLTag(obj); StrAllocCat(new_markup, tmp_markup); FREE_AND_CLEAR(tmp_markup); } else if(*cp == '<') { /* protect ourselves from markup */ if(!obj->in_broken_html) { obj->in_broken_html = TRUE; StrAllocCopy(new_markup, BEGIN_BROKEN_ATTRIBUTE_MARKUP); StrAllocCat(new_markup, "<"); } else { StrAllocCopy(new_markup, "<"); } } else { if (obj->tag_index < MAXTAGLEN) obj->tag[obj->tag_index++] = *cp; } break; case IN_TAG: /* do nothing until you find a opening '=' or end '>' */ if(*cp == '=') { StrAllocCopy(new_markup, "="); StrAllocCat(new_markup, BEGIN_ATTRIBUTE_VALUE_MARKUP); obj->state = BEGIN_ATTRIBUTE_VALUE; } else if(*cp == '>') { new_markup = net_EndColorHTMLTag(obj); } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } break; case BEGIN_ATTRIBUTE_VALUE: /* when we reach the first non-whitespace * we will enter the UNQUOTED or the QUOTED * ATTRIBUTE state */ if(!XP_IS_SPACE(*cp)) { if(*cp == '"') { obj->state = IN_QUOTED_ATTRIBUTE_VALUE; /* no need to jump to the quoted attr handler * since this char can't be a dangerous char */ } else { obj->state = IN_UNQUOTED_ATTRIBUTE_VALUE; /* need to jump to the unquoted attr handler * since this char can be a dangerous character */ goto unquoted_attribute_jump_point; } } else if(*cp == '>') { StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP); tmp_markup = net_EndColorHTMLTag(obj); StrAllocCat(new_markup, tmp_markup); FREE_AND_CLEAR(tmp_markup); } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } break; case IN_UNQUOTED_ATTRIBUTE_VALUE: unquoted_attribute_jump_point: /* do nothing until you find a whitespace */ if(XP_IS_SPACE(*cp)) { StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP); XP_SPRINTF(tiny_buf, "%c", *cp); StrAllocCat(new_markup, tiny_buf); obj->state = IN_TAG; } else if(*cp == '>') { StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP); tmp_markup = net_EndColorHTMLTag(obj); StrAllocCat(new_markup, tmp_markup); FREE_AND_CLEAR(tmp_markup); } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } else if(*cp == '&') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "&"); } break; case IN_QUOTED_ATTRIBUTE_VALUE: /* do nothing until you find a closing '"' */ if(*cp == '\"') { if(obj->in_broken_html) { StrAllocCopy(new_markup, END_BROKEN_ATTRIBUTE_MARKUP); obj->in_broken_html = FALSE; } StrAllocCat(new_markup, "\""); StrAllocCat(new_markup, END_ATTRIBUTE_VALUE_MARKUP); obj->state = IN_TAG; } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } else if(*cp == '&') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "&"); } else if(*cp == '>') { /* probably a broken attribute value */ if(!obj->in_broken_html) { obj->in_broken_html = TRUE; StrAllocCopy(new_markup, BEGIN_BROKEN_ATTRIBUTE_MARKUP); StrAllocCat(new_markup, ">"); } } break; case IN_COMMENT: /* do nothing until you find a closing '-->' */ if(!XP_STRNCMP(cp, "-->", 3)) { StrAllocCopy(new_markup, ">"); cp += 2; i += 2; StrAllocCat(new_markup, END_COMMENT_MARKUP); obj->state = IN_CONTENT; } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } break; case IN_AMPERSAND_THINGY: /* do nothing until you find a ';' or space */ if(*cp == ';' || XP_IS_SPACE(*cp)) { XP_SPRINTF(tiny_buf, "%c", *cp); StrAllocCopy(new_markup, tiny_buf); StrAllocCat(new_markup, END_AMPERSAND_THINGY_MARKUP); obj->state = IN_CONTENT; } else if(*cp == '<') { /* protect ourselves from markup */ StrAllocCopy(new_markup, "<"); } break; default: XP_ASSERT(0); break; } if(new_markup) { /* push all the way up to but not including *cp */ status = (*obj->next_stream->put_block) (obj->next_stream, &s[last_output_point], i-last_output_point); last_output_point = i+1; if(status < 0) { FREE(new_markup); return(status); } /* add new markup */ status = (*obj->next_stream->put_block) (obj->next_stream, new_markup, XP_STRLEN(new_markup)); if(status < 0) { FREE(new_markup); return(status); } FREE_AND_CLEAR(new_markup); } } if(last_output_point < l) return((*obj->next_stream->put_block)(obj->next_stream, &s[last_output_point], (l-last_output_point))); else return(0); }
int XFE_ComposeAttachFolderView::validateAttachment(Widget widget,const char *url) { if (!url) return FALSE; // strip off any file: prefix before validating const char *data=url; if (XP_STRNCASECMP(url,"file:",5)==0) data=url+5; if (strlen(data)==0) return FALSE; // accept only URL's that resolve to a document // reject mailto:, mailbox: folders etc. if (NET_URL_Type(data)!=0) { // reject addressbook add command, without error dialog if (XP_STRNCASECMP(url,"addbook:add?vcard=",18)==0) return FALSE; // accept regular address book cards if (XP_STRNCASECMP(url,"addbook:",8)==0) return TRUE; // accept anything we know how to display as a document if (MSG_RequiresMailMsgWindow(url) || MSG_RequiresNewsMsgWindow(url) || MSG_RequiresBrowserWindow(url)) return TRUE; else { char *msg=PR_smprintf(XP_GetString(XFE_MN_INVALID_ATTACH_URL),data); if (msg) { fe_Alert_2(widget,msg); XP_FREE(msg); } return FALSE; } } // file must exist if (!fe_isFileExist((char*)data)) { char *msg=PR_smprintf(XP_GetString(XFE_INVALID_FILE_ATTACHMENT_DOESNT_EXIST),data); if (msg) { fe_Alert_2(widget,msg); XP_FREE(msg); } return FALSE; } // file must be readable if (!fe_isFileReadable((char*)data)) { char *msg=PR_smprintf(XP_GetString(XFE_INVALID_FILE_ATTACHMENT_NOT_READABLE),data); if (msg) { fe_Alert_2(widget,msg); XP_FREE(msg); } return FALSE; } // cannot attach directory if (fe_isDir((char*)data)) { char *msg=PR_smprintf(XP_GetString( XFE_INVALID_FILE_ATTACHMENT_IS_A_DIRECTORY ),data); if (msg) { fe_Alert_2(widget,msg); if (msg) XP_FREE(msg); } return FALSE; } return TRUE; }