if (!base_url) { base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_LOCATION, PR_FALSE, PR_FALSE); }
MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child){  MimeMultipartRelated *relobj = (MimeMultipartRelated *) obj;  /* rhp - Changed from "if (relobj->head_loaded)" alone to support the            start parameter   */  if (       (relobj->head_loaded) ||        (MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child))      )  {    /* This is a child part.  Just remember the mapping between the URL       it represents and the part-URL to get it back. */    /* but first before acceptig it as a valid related part, make sure we       are able to display it inline as an embedded object. Else just ignore       it, that will prevent any bad surprise. */    MimeObjectClass *clazz = mime_find_class (child->content_type, child->headers, child->options, PR_FALSE);    PRBool canDisplay = (clazz          ? clazz->displayable_inline_p(clazz, child->headers)          : PR_FALSE);    if (canDisplay) {    char* location = MimeHeaders_get(child->headers, HEADER_CONTENT_LOCATION,                     PR_FALSE, PR_FALSE);    if (!location) {      char* tmp = MimeHeaders_get(child->headers, HEADER_CONTENT_ID,                    PR_FALSE, PR_FALSE);      if (tmp) {        char* tmp2 = tmp;        if (*tmp2 == '<') {          int length;          tmp2++;          length = strlen(tmp2);          if (length > 0 && tmp2[length - 1] == '>') {            tmp2[length - 1] = '\0';          }        }        location = PR_smprintf("cid:%s", tmp2);        PR_Free(tmp);      }    }    if (location) {      char *absolute;      char *base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_BASE,                       PR_FALSE, PR_FALSE);      /* rhp: need this for supporting Content-Location */      if (!base_url)      {        base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_LOCATION, PR_FALSE, PR_FALSE);      }      /* rhp: need this for supporting Content-Location */      absolute = MakeAbsoluteURL(base_url ? base_url : relobj->base_url, location);      PR_FREEIF(base_url);      PR_Free(location);      if (absolute) {        nsCAutoString partnum;        partnum.Adopt(mime_part_address(child));        if (!partnum.IsEmpty()) {          /*            AppleDouble part need special care: we need to output only the data fork part of it.            The problem at this point is that we haven't yet decoded the children of the AppleDouble            part therfore we will have to hope the datafork is the second one!          */          if (mime_typep(child, (MimeObjectClass *) &mimeMultipartAppleDoubleClass))            partnum.Append(".2");          char* part;          part = mime_set_url_part(obj->options->url, partnum.get(),                       PR_FALSE);          if (part) {            char *name = MimeHeaders_get_name(child->headers, child->options);            // let's stick the filename in the part so save as will work.            if (name)            {              char *savePart = part;              part = PR_smprintf("%s&filename=%s", savePart, name);              PR_Free(savePart);              PR_Free(name);            }            char *temp = part;            /* If there's a space in the url, escape the url.               (This happens primarily on Windows and Unix.) */            if (PL_strchr(part, ' ') || PL_strchr(part, '>') || PL_strchr(part, '%'))              temp = escape_for_mrel_subst(part);              MimeHashValue * value = new MimeHashValue(child, temp);              PL_HashTableAdd(relobj->hash, absolute, value);            /* rhp - If this part ALSO has a Content-ID we need to put that into                     the hash table and this is what this code does             */            {              char *tloc;              char *tmp = MimeHeaders_get(child->headers, HEADER_CONTENT_ID, PR_FALSE, PR_FALSE);              if (tmp)               {                char* tmp2 = tmp;                if (*tmp2 == '<')                 {                  int length;                  tmp2++;                  length = strlen(tmp2);                  if (length > 0 && tmp2[length - 1] == '>')                   {                    tmp2[length - 1] = '\0';                  }                }                                tloc = PR_smprintf("cid:%s", tmp2);                PR_Free(tmp);                if (tloc)                {                    MimeHashValue * value = new MimeHashValue(child, temp);                    PL_HashTableAdd(relobj->hash, tloc, value);                }              }            }            /*  rhp - End of putting more stuff into the hash table */              /* it's possible that temp pointer is the same than the part pointer,                 therefore be carefull to not freeing twice the same pointer */              if (temp && temp != part)                PR_Free(temp);              PR_Free(part);            }          }        }      }    }  } else {    /* Ah-hah!  We're the head object.  */    char* base_url;    relobj->head_loaded = PR_TRUE;    relobj->headobj = child;    relobj->buffered_hdrs = MimeHeaders_copy(child->headers);    base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_BASE,                   PR_FALSE, PR_FALSE);    /* rhp: need this for supporting Content-Location */    if (!base_url)    {      base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_LOCATION, PR_FALSE, PR_FALSE);    }    /* rhp: need this for supporting Content-Location */    if (base_url) {      /* If the head object has a base_url associated with it, use         that instead of any base_url that may have been associated         with the multipart/related. */      PR_FREEIF(relobj->base_url);      relobj->base_url = base_url;    }  }  if (obj->options && !obj->options->write_html_p#ifdef MIME_DRAFTS    && !obj->options->decompose_file_p#endif /* MIME_DRAFTS */    )    {    return PR_TRUE;    }  return PR_FALSE;      /* Don't actually parse this child; we'll handle                 all that at eof time. */}