Ejemplo n.º 1
0
struct file_download *init_file_download( struct uri *uri, struct session *ses, unsigned char *file, int fd )
{
  struct file_download *file_download;
  if ( mem_calloc( 1, 116 ) )
  {
    file_download->uri = get_composed_uri( uri, URI_BASE );
    if ( file_download->uri == 0 )
    {
      &file_download[0] = 0;
      mem_free( (void*)file_download[0].next );
      return downloads.next + 4;
    }
    init_download_display( &file_download[0] );
    file_download->file = file;
    file_download->download.callback = &download_data;
    file_download->download.data = (void*)file_download[0].next;
    file_download->ses = &ses[0];
    file_download->handle = fd;
    file_download->term = ses->tab->term;
    file_download->prev = &downloads.next[0];
    &file_download = &downloads->next[0];
    downloads.next = (void*)file_download[0].next;
    file_download->prev = &file_download[0];
    return downloads.next + 4;
  }
  else
  {
    return downloads.next + 4;
  }
}
Ejemplo n.º 2
0
static struct uri *
get_auth_entry_uri(struct listbox_item *item)
{
	struct auth_entry *auth_entry = (struct auth_entry *)item->udata;

	return get_composed_uri(auth_entry->uri, URI_HTTP_AUTH);
}
Ejemplo n.º 3
0
struct uri *
get_proxied_uri(struct uri *uri)
{
    if (uri->protocol == PROTOCOL_PROXY)
        return get_uri(uri->data, URI_BASE);

    return get_composed_uri(uri, URI_BASE);
}
Ejemplo n.º 4
0
static void
auth_ok(void *data)
{
	struct dialog *dlg = (struct dialog *)data;
	struct auth_entry *entry = (struct auth_entry *)dlg->udata2;
	struct session *ses = (struct session *)dlg->udata;

	entry->blocked = 0;
	entry->valid = auth_entry_has_userinfo(entry);

#ifdef CONFIG_FORMHIST
	if (get_opt_bool((const unsigned char *)"document.browse.forms.show_formhist", ses)) {
		unsigned char *url = get_uri_string(entry->uri, URI_HTTP_AUTH);

		if (url) {
			struct form form = {};

			form.action = url;
			INIT_LIST_OF(struct submitted_value, submit);
			struct submitted_value *user, *password;

			user = init_submitted_value((unsigned char *)"user", entry->user, FC_TEXT, NULL, 0);
			if (user) {
				add_to_list(submit, user);
			}
			password = init_submitted_value((unsigned char *)"password", entry->password, FC_PASSWORD, NULL, 0);
			if (password) {
				add_to_list(submit, password);
			}

			memorize_form(ses, &submit, &form);
			done_submitted_value_list(&submit);
			mem_free(url);
		}
	}
#endif

	if (entry->valid && have_location(ses)) {
		struct location *loc = cur_loc(ses);
		struct uri *uri = loc->vs.uri;

		/* Make a 'fake' redirect to a URI without user/password so that
		 * the user/password from the URI will not override what the
		 * user just entered in the dialog. */
		if ((uri->userlen && strlcmp(entry->user, -1, uri->user, uri->userlen))
		    || (uri->password && strlcmp(entry->password, -1, uri->password, uri->passwordlen))) {

			uri = get_composed_uri(uri, URI_HTTP_AUTH | URI_DATA | URI_POST);
			if (uri) {
				goto_uri_frame(ses, uri, NULL, CACHE_MODE_INCREMENT);
				done_uri(uri);
				return;
			}
		}
	}

	reload(ses, CACHE_MODE_INCREMENT);
}
Ejemplo n.º 5
0
void auth_ok( void *data )
{
  int edx;
  struct auth_entry *entry = &((int*)data)[2];
  struct session *ses = &((int*)data)[1];
  ((int*)data)[2] = ((int*)data)[2] & -2;
  entry->bits_at_112/*.1_1of4*/ = ( (int)entry->bits_at_112/*.1_1of4*/ & -2 & -3 ) | ( ( entry->user[0] == 0 ? 1 : entry->password[0] != 0 ) * 2 );
  if ( ( ( (unsigned char)( ( (int)entry->bits_at_112/*.1_1of4*/ & -2 & -3 ) | ( ( entry->password[0] != 0 ) * 2 ) ) & 2 ) & 255 ) && ses->history.current )
  {
    struct uri *uri = ses->history.current->vs.uri;
    if ( uri->bits_at_40/*.3_4of4*/ )
    {
      errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/dialogs.c";
      errline = 45;
      if ( elinks_strlcmp( &entry->user[0], -1, uri->user, uri->bits_at_40/*.3_4of4*/ ) )
      {
        uri = get_composed_uri( &uri[0], -32077 );
        if ( get_composed_uri( &uri[0], -32077 ) )
        {
          goto_uri_frame( &ses[0], get_composed_uri( &uri[0], -32077 ), 0, CACHE_MODE_INCREMENT );
          data = (void*)uri[0].string;
        }
      }
    }
    if ( uri->password )
    {
      errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/dialogs.c";
      errline = 46;
      if ( elinks_strlcmp( entry->password[0] + 72, -1, uri->password, (int)uri->bits_at_44/*.1_2of4*/ ) )
      {
        uri = get_composed_uri( &uri[0], -32077 );
      }
    }
  }
  reload( &ses[0], CACHE_MODE_INCREMENT );
  return;
}
Ejemplo n.º 6
0
struct uri *
get_proxy_uri(struct uri *uri, struct connection_state *error_state)
{
    if (uri->protocol == PROTOCOL_PROXY) {
        return get_composed_uri(uri, URI_BASE);
    } else {
#ifdef CONFIG_SCRIPTING
        unsigned char *tmp = NULL;
        static int get_proxy_event_id = EVENT_NONE;

        set_event_id(get_proxy_event_id, "get-proxy");
        trigger_event(get_proxy_event_id, &tmp, struri(uri));

        uri = get_proxy_worker(uri, tmp, error_state);
        mem_free_if(tmp);
        return uri;
#else
        return get_proxy_worker(uri, NULL, error_state);
#endif
    }
}
Ejemplo n.º 7
0
static struct uri *
get_proxy_worker(struct uri *uri, unsigned char *proxy,
                 struct connection_state *error_state)
{
    unsigned char *protocol_proxy = NULL;

    if (proxy) {
        if (*proxy) {
            proxy = strip_proxy_protocol(proxy, (unsigned char *)"http://", (unsigned char *)"ftp://");

            return proxy_uri(uri, proxy, error_state);
        }

        /* "" from script_hook_get_proxy() */
        return get_composed_uri(uri, URI_BASE);
    }

    switch (uri->protocol) {
    case PROTOCOL_HTTP:
        protocol_proxy = get_protocol_proxy((unsigned char *)"protocol.http.proxy.host",
                                            (unsigned char *)"HTTP_PROXY", (unsigned char *)"http_proxy",
                                            (unsigned char *)"http://", NULL);
        break;

    case PROTOCOL_HTTPS:
        /* As Timo Lindfors explains, the communication between ELinks
         * and the proxy server is never encrypted, altho the proxy
         * might be used to transfer encrypted data between Web client
         * and Web server. (Some proxy servers might allow encrypted
         * communication between the Web client and the proxy
         * but ELinks does not support that.) */
        /* So, don't check whether the URI for the proxy begins
         * with "https://" but rather check for "http://".
         * Maybe we should allow either -- ELinks uses HTTP
         * to communicate with the proxy when we use it for FTP, but we
         * check for "ftp://" below; and what about 'be liberal in what
         * you accept' (altho that is usually applied to data received
         * from remote systems, not to user input)?  -- Miciah */
        protocol_proxy = get_protocol_proxy((unsigned char *)"protocol.https.proxy.host",
                                            (unsigned char *)"HTTPS_PROXY", (unsigned char *)"https_proxy",
                                            (unsigned char *)"http://", NULL);
        break;

    case PROTOCOL_FTP:
        protocol_proxy = get_protocol_proxy((unsigned char *)"protocol.ftp.proxy.host",
                                            (unsigned char *)"FTP_PROXY", (unsigned char *)"ftp_proxy",
                                            (unsigned char *)"ftp://", (unsigned char *)"http://");
        break;
    }

    if (protocol_proxy && *protocol_proxy) {
        unsigned char *no_proxy;
        unsigned char *slash = (unsigned char *)strchr((char *)protocol_proxy, '/');

        if (slash) *slash = 0;

        no_proxy = get_opt_str((const unsigned char *)"protocol.no_proxy", NULL);
        if (!*no_proxy) no_proxy = (unsigned char *)getenv("NO_PROXY");
        if (!no_proxy || !*no_proxy) no_proxy = (unsigned char *)getenv("no_proxy");

        if (!proxy_probe_no_proxy(uri->host, no_proxy))
            return proxy_uri(uri, protocol_proxy, error_state);
    }

    return get_composed_uri(uri, URI_BASE);
}
Ejemplo n.º 8
0
struct uri *get_auth_entry_uri( struct listbox_item *item )
{
  return get_composed_uri( &item->udata[3], URI_HTTP_AUTH );
}