1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-20 01:46:15 -04:00
Commit Graph

440 Commits

Author SHA1 Message Date
Kalle Olavi Niemitalo
687f19dbde Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:
	src/bfu/dialog.c
	src/bfu/hotkey.c
	src/bfu/inpfield.c
	src/dialogs/options.c
	src/document/renderer.c
	src/intl/gettext/libintl.h
	src/protocol/http/codes.c
	src/session/task.c
	src/terminal/event.c
	src/terminal/terminal.h
	src/viewer/text/form.c
	src/viewer/text/link.c

And a semantic conflict in src/terminal/terminal.c.
2009-01-01 19:14:01 +00:00
Kalle Olavi Niemitalo
ad45176dde Add get_terminal_codepage().
This simplifies the callers a little and may help implement
simultaneous support for different charsets on different terminals
of the same type (bug 1064).
2009-01-01 16:16:17 +00:00
Witold Filipczyk
5755137630 Big file upload failed with https, because 32768 bytes is too big for SSL,
16384 is OK.
2008-11-28 18:58:19 +01:00
Kalle Olavi Niemitalo
5c2fada371 Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:
	src/session/download.c
2008-11-01 22:39:17 +02:00
M. Vefa Bicakci
20a7a6c460 Patch 3: Further fixes including strcasestr and convert_to_lowercase 2008-11-01 22:32:43 +02:00
M. Vefa Bicakci
96b3093519 Patch 2: Modifications to the remaining parts of ELinks
[Forward ported to 0.12 from bug 1004 attachment 499.  --KON]
2008-11-01 22:20:25 +02:00
Kalle Olavi Niemitalo
84e19d0e4e bug 1054: Don't abort downloads when closing a terminal.
Except if they have external handlers.

When ELinks receives an event from a terminal, move that terminal to
the beginning of the global "terminals" list, so that the terminals
are always sorted according to the time of the most recent use.  Note,
this affects the numbering of bookmark folders in session snapshots.

Add get_default_terminal(), which returns the most recently used
terminal that is still open.  Use that in various places that
previously used terminals.prev or terminals.next.  Four functions
fetch the size of the terminal for User-Agent headers, and
get_default_terminal() is not really right, but neither was the
original code; add TODO comments in those functions.

When the user chooses "Background and Notify", associate the download
with the terminal where the dialog box is.  So any later messages will
then appear in that terminal, if it is still open.  However, don't
change the terminal if the download has an external handler.

When a download gets some data, don't immediately check the associated
terminal.  Instead, wait for the download to end.  Then, if the
terminal of the download has been closed, use get_default_terminal()
instead.  If there is no default terminal either, just skip any
message boxes.
2008-10-15 23:29:25 +03:00
Kalle Olavi Niemitalo
b40736cafe Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:

	NEWS (merged)
	configure.in (merged)
	doc/man/man1/elinks.1.in (regenerated)
	doc/man/man5/elinks.conf.5 (regenerated)
	doc/man/man5/elinkskeys.5 (regenerated)
	po/fr.po (kept 0.13.GIT version)
	po/pl.po (kept 0.13.GIT version)
2008-09-27 16:28:28 +03:00
Kalle Olavi Niemitalo
d93bceb9bd Fix blacklist crash in BitTorrent
make_bittorrent_peer_connection() used to construct a struct uri on
the stack. This was hacky but worked nicely because the struct uri
was not really accessed after make_connection() returned.  However,
since commit a83ff1f565, the struct uri
is also needed when the connection is being closed.  Valgrind shows:

Invalid read of size 2
   at 0x8100764: get_blacklist_entry (blacklist.c:33)
   by 0x8100985: del_blacklist_entry (blacklist.c:64)
   by 0x80DA579: complete_connect_socket (socket.c:448)
   by 0x80DA84A: connected (socket.c:513)
   by 0x80D0DDF: select_loop (select.c:297)
   by 0x80D00C6: main (main.c:353)
 Address 0xBEC3BFAE is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes

To fix this, allocate the struct uri on the heap instead, by
constructing a string and giving that to get_uri().  This string
cannot use the "bittorrent" URI scheme because parse_uri() does not
recognize the host and port fields in that.  (The "bittorrent" scheme
has protocol_backend.free_syntax = 1 in order to support strings like
"bittorrent:http://beta.legaltorrents.com/get/159-noisome-beasts".)
Instead, define a new "bittorrent-peer" URI scheme for this purpose.
If the user attempts to use this URI scheme, its handler aborts the
connection with an error; but when make_bittorrent_peer_connection()
uses a bittorrent-peer URI, the handler is not called.

This change also lets get_uri() set the ipv6 flag if peer_info->ip is
an IPv6 address literal.

Reported by Witold Filipczyk.
2008-09-07 06:31:36 +03:00
Kalle Olavi Niemitalo
80a5c6d466 Merge branch 'elinks-0.12' into elinks-0.13 2008-09-04 12:08:38 +03:00
Kalle Olavi Niemitalo
7de8b9940c Bug 1013: Fix type mismatches in gopher.c
When I replaced enum connection_state with struct connection_state,
I missed parts of src/protocol/gopher/gopher.c.  Finish the change there.
2008-09-04 11:57:03 +03:00
Kalle Olavi Niemitalo
b7d3b4f687 1041: Add ftp_add_unparsed_line: HTML entities and more error checks.
Separate the formatting of unparsed lines from ftp_process_dirlist()
to a new function ftp_add_unparsed_line().  Check for all possible
out-of-memory errors.  Encode HTML metacharacters as entity references
and document how charsets are handled FTP directory listings.
Add a NEWS entry.
2008-09-04 11:21:06 +03:00
Witold Filipczyk
298f3af6c6 1041: Do not show the "Error parsing" on ftp://sunsite.icm.edu.pl/. 2008-09-04 10:24:42 +03:00
Kalle Olavi Niemitalo
a73fe73cd2 Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:

	src/document/document.h
	src/encoding/encoding.c
	src/network/connection.c
	src/protocol/bittorrent/bittorrent.c
	src/protocol/bittorrent/bittorrent.h
	src/protocol/bittorrent/common.h
	src/protocol/bittorrent/connection.c
	src/protocol/bittorrent/dialogs.c
	src/protocol/bittorrent/tracker.c
	src/protocol/file/cgi.c
	src/protocol/http/http.c
2008-08-03 22:18:53 +03:00
Kalle Olavi Niemitalo
c1ffba2f95 Work around fsp_open_session() not setting errno.
fsp_open_session() has a bug where it does not set errno if getaddrinfo fails.
Before the bug 1013 fix, this caused an assertion failure.
After the bug 1013 fix, this caused a "Success" error message.
Now it instead causes "FSP server not found".
2008-08-03 20:26:50 +03:00
Kalle Olavi Niemitalo
6c2e8cd7b2 Bug 1013: Don't assume errno is between 0 and 100000
Replace almost all uses of enum connection_state with struct
connection_status.  This removes the assumption that errno values used
by the system are between 0 and 100000.  The GNU Hurd uses values like
ENOENT = 0x40000002 and EMIG_SERVER_DIED = -308.

This commit is derived from my attachments 450 and 467 to bug 1013.
2008-08-03 17:56:41 +03:00
Kalle Olavi Niemitalo
a83ff1f565 1040: Blacklist servers that support SSL3 but not TLS1.
It seems GnuTLS is not as good at negotiating a supported protocol as
OpenSSL is.  ELinks tries to work around that by retrying with a
different protocol if the SSL library reports an error.  However,
ELinks must not automatically retry POST requests where some data may
have already reached the server; POST is not a safe method in HTTP.
So instead, collect the name of the TLS-incapable server in a blacklist
when ELinks e.g. loads an HTML form from it; the actual POST can then
immediately use the protocol that worked.

It's a bit ugly that src/network/socket.c now uses
protocol/http/blacklist.h.  It might be better to move the blacklist
files out of the http directory, and perhaps merge them with the
BitTorrent blacklisting code.
2008-07-27 01:39:01 +03:00
Kalle Olavi Niemitalo
988cec481b Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:

	NEWS
	configure.in

The following files also conflicted, but they had not been manually
edited in the elinks-0.12 branch after the previous merge, so I just
kept the 0.13.GIT versions:

	doc/man/man1/elinks.1.in
	doc/man/man5/elinks.conf.5
	doc/man/man5/elinkskeys.5
	po/fr.po
	po/pl.po
2008-07-11 22:28:45 +03:00
Kalle Olavi Niemitalo
1ab55c27a4 1008: make http_post.post_data point to const
Because init_http_post() now copies the file names,
http_read_post_inline() no longer writes '\0' into post_data.
2008-07-11 15:18:01 +03:00
Kalle Olavi Niemitalo
42123dab87 1008: percent-encode file names in uri.post
In uri.post, each file name begins and ends with FILE_CHAR.
Previously, file names were not encoded, and names containing
FILE_CHAR could not be used.  Because FILE_CHAR is a control
character, the user cannot directly type it in a file input field,
so ELinks asserted that the field did not contain FILE_CHAR.
However, it is possible to get FILE_CHAR in a file input field
with file name completion (ACT_EDIT_AUTO_COMPLETE), causing the
assertion to fail.  Now, ELinks encodes FILE_CHAR as "%02", so it
is no longer ambiguous and the assertion is not needed.
2008-07-11 14:44:35 +03:00
Kalle Olavi Niemitalo
50a3244dfb 1008: document the format of uri.string and uri.post 2008-07-11 14:20:47 +03:00
Kalle Olavi Niemitalo
5c0128d82d Bug 1021: initialize version in http_got_header
gcc-4.3 -O2 was complaining that http_got_header may use uninitialized
version.major and version.minor.  That indeed happened with HTTP/0.9
servers, and the PRE_HTTP_1_1(version) check then had an undefined
result, so http->close could remain 0 even though it should have
become 1; fortunately, it was then set to 1 anyway, because there was
no Content-Length header.  The undefined version was also saved in
http->recv_version, but it appears nothing ever reads that.  So in the
end, the bug did not cause any symptoms at runtime, but the warning
broke the build on gcc-4.3 if ELinks was configured with --enable-debug.
2008-07-04 16:42:35 +03:00
Kalle Olavi Niemitalo
5b6c913c6a Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:

	src/network/connection.h
	src/session/download.c
	src/session/download.h
2008-06-15 21:43:08 +03:00
Kalle Olavi Niemitalo
69cae5d791 Revert "Gradual rendering in pager mode. ELinks is almost as good as less."
I am reverting all /dev/fd recognition because of bug 917.
This reverts commit c283f8cfd9,
except src/protocol/file/file.c still needs #include "osdep/osdep.h"
for STRING_DIR_SEP.
2008-06-15 19:31:29 +03:00
Kalle Olavi Niemitalo
006b68716b Revert "set_nonblocking_fd seems to be superfluous"
I am reverting all /dev/fd recognition because of bug 917.
This reverts commit 9c3817675f.
2008-06-15 19:24:53 +03:00
Kalle Olavi Niemitalo
bfb034c953 Revert "copiousoutput: cleanup after copiousoutput handling. Temporary files should"
I am reverting all copiousoutput support because of bug 917.
This reverts commit 4dc4ea47f2.

Conflicts:

	src/network/connection.h: After the original commit, the declaration
	  of copiousoutput_data had been changed to use the LIST_OF macro.
	  Also, connection.cgi had been added next to the connection.popen
	  member added by the original commit.
	src/session/download.c: After the original commit, the definition of
	  copiousoutput_data had been changed to use the INIT_LIST_OF macro.
2008-06-15 14:17:44 +03:00
Kalle Olavi Niemitalo
5ef6c9e395 Revert "copiousoutput: only mark /dev/fd/%d as popen data . I reflect if ELinks may"
I am reverting all copiousoutput support because of bug 917.
This reverts commit f377e6f4af.
2008-06-15 14:09:12 +03:00
Witold Filipczyk
1544b5f4b9 bug 991: fix crash when the file is already cached
If the user opens the same file again after it is in the cache, then
ELinks does not always open a new connection, so download->conn can be
NULL in init_type_query(), and download->conn->cgi would crash.
Don't read that, then; instead add a new flag cache_entry.cgi, which
http_got_header() sets or clears as soon as possible after the cache
entry has been created.
(cherry picked from commit 81f8ee1fa2)
2008-06-15 13:53:34 +03:00
Witold Filipczyk
d15439edff bug 991: Added the bit field cgi to the structs connection and type_query.
CGI scripts are distinguishable from normal files. I hope that this
fixes the bug 991. This commit also reverts the previous revert.
(cherry picked from commit 7ceba1e461)
2008-06-15 13:07:02 +03:00
Kalle Olavi Niemitalo
a3fba83f80 Remove a comment about kill_timer()
The comment said "it is not possible to call kill_timer from a timer
handler."  Sure, such calls used to crash occasionally, but that was
bug 868 and has already been fixed.
2008-06-15 11:41:52 +03:00
Kalle Olavi Niemitalo
d6fd2ac31f Erase progress.timer before calling progress.timer_func
Previously, each progress timer function registered with
start_update_progress() was directly used as the timer function of
progress.timer, so it was responsible of erasing the expired timer ID
from that member.  Failing to do this could result in heap corruption.
The progress timer functions normally fulfilled the requirement by
calling update_progress(), but one such function upload_stat_timer()
had to erase the timer ID on its own too.

Now instead, there is a wrapper function progress_timeout(), which
progress.c sets as the timer function of progress.timer.  This wrapper
erases the expired timer ID from progress.timer and then calls the
progress timer function registered with start_update_progress().  So
the progress timer function is no longer responsible of erasing the
timer ID and there's no risk that it could fail to do that in some
error situation.

This commit introduces a new risk though.  Previously, if the struct
progress was freed while the timer was running, the (progress) timer
function would still be called, and it would be able to detect that
the progress pointer is NULL and recover from this situation.  Now,
the timer function progress_timeout() has a pointer to the struct
progress and will dereference that pointer without being able to check
whether the structure has been freed.  Fortunately, done_progress()
asserts that the timer is not running, so this should not occur.
2008-06-15 11:27:19 +03:00
Kalle Olavi Niemitalo
696496e831 1008: remove unused uri.big_files
The files are instead counted by open_http_post().
2008-06-10 01:05:39 +03:00
Kalle Olavi Niemitalo
b8b54a5325 Merge branch 'top/0.13/bug1008' into elinks-0.13 2008-06-08 19:51:00 +03:00
Kalle Olavi Niemitalo
d2da3f4967 1008: larger POST_BUFFER_SIZE for CPU efficiency
Posting a 91762123-byte file to test/cgi/big_file.cgi.  The CPU
percentages are from "top" set up to update every 10 seconds and
checked near the end of the transfer, so they are less accurate
than the upload rate, which averages over the whole transfer.

buffer=4096: average 1.7 MiB/s, elinks 62% CPU, python 35% CPU.
buffer=8192: average 2.5 MiB/s, elinks 49% CPU, python 42% CPU.
buffer=16384: average 3.1 MiB/s, elinks 40% CPU, python 55% CPU.
buffer=32768: average 3.8 MiB/s, elinks 33% CPU, python 61% CPU.
buffer=65536: average 4.1 MiB/s, elinks 26% CPU, python 70% CPU.
buffer=131072: average 4.2 MiB/s, elinks 28% CPU, python 67% CPU.
buffer=262144: average 4.4 MiB/s, elinks 26% CPU, python 69% CPU.

I'm choosing 32768 as POST_BUFFER_SIZE because the advantages of
larger buffers don't seem very high and keeping this under 65536
may help anyone trying to port ELinks to DOS.

I'm using the same value for HTTP too, just to keep things consistent
until there is a reason to diverge.
2008-06-08 18:38:48 +03:00
Kalle Olavi Niemitalo
5839aa070a 1008: show upload progress in local CGI too 2008-06-08 17:30:17 +03:00
Kalle Olavi Niemitalo
bed84c483e Bug 517: read_encoded() == 0 might not mean EOF if non-blocking.
Without this patch, ELinks showed garbage at
<http://www.dwheeler.com/oss_fs_why.html> when bzip2 decompression was
enabled.  safe_read() in bzip2_read() did not see all of the body
bytes that ELinks had received from the server.  After bzip2_read()
received EAGAIN from safe_read() and returned 0, something skipped
1460 bytes.

decompress_data() apparently assumed that read_encoded() returning 0
meant the end of the file, and returned even though len still was
nonzero, i.e. it had not yet written to the pipe all the data that
the caller (read_chunked_http_data() or read_normal_http_data()) had
provided.  The caller did not know this, and discarded the data.
(cherry picked from commit 7e5e05ca60)
2008-06-07 23:33:23 +03:00
Kalle Olavi Niemitalo
7e5e05ca60 Bug 517: read_encoded() == 0 might not mean EOF if non-blocking.
Without this patch, ELinks showed garbage at
<http://www.dwheeler.com/oss_fs_why.html> when bzip2 decompression was
enabled.  safe_read() in bzip2_read() did not see all of the body
bytes that ELinks had received from the server.  After bzip2_read()
received EAGAIN from safe_read() and returned 0, something skipped
1460 bytes.

decompress_data() apparently assumed that read_encoded() returning 0
meant the end of the file, and returned even though len still was
nonzero, i.e. it had not yet written to the pipe all the data that
the caller (read_chunked_http_data() or read_normal_http_data()) had
provided.  The caller did not know this, and discarded the data.
2008-06-07 21:27:37 +03:00
Kalle Olavi Niemitalo
08941fd47d 1008: rename connection.upload_progress to .http_upload_progress 2008-06-03 09:57:58 +03:00
Kalle Olavi Niemitalo
fa51846f68 1008: increment http_post->uploaded in read_http_post() 2008-06-03 09:45:40 +03:00
Kalle Olavi Niemitalo
2d2cc6c5f5 1008: Abort connection if a file is resized. 2008-06-03 01:49:10 +03:00
Kalle Olavi Niemitalo
d3ee4e2e47 1008: error parameter in read_http_post
This function will need to set ELinks-specific errors
and it would not be right to write those in errno.
2008-06-03 01:26:19 +03:00
Kalle Olavi Niemitalo
44bf538cab 1008: Remember the sizes of files during the upload.
This will soon allow read_http_post_fd() to detect if a size has
changed.
2008-06-03 00:46:12 +03:00
Kalle Olavi Niemitalo
c2d854b240 1008: open_http_post() can return an error.
It does not yet take advantage of that though.
2008-06-03 00:18:47 +03:00
Kalle Olavi Niemitalo
533e7fc62b 1008: replace post_length() with open_http_post() 2008-06-02 10:41:55 +03:00
Kalle Olavi Niemitalo
88a59a06c0 1008: move stuff to new src/protocol/http/post.{c,h} 2008-06-02 10:40:34 +03:00
Kalle Olavi Niemitalo
0a95ae85ab 1008: finish renaming http_read_post_data to read_http_post
Fix the compilation error caused in the previous commit.
2008-06-02 01:06:23 +03:00
Kalle Olavi Niemitalo
4768243d0c 1008: rename http_read_post_data to read_http_post 2008-05-26 10:40:43 +03:00
Kalle Olavi Niemitalo
1b707208d3 1008: New struct http_post.
Move connection.post_fd to http_post.post_fd.
Make connection.done point to the new done_http_connection(),
which calls the new done_http_post(), which closes post_fd.
So done_connection() no longer needs to do that.

Now that done_http_post() exists, a later commit can add dynamically
allocated data in struct http_post and ensure that it will be freed.
2008-05-26 01:56:58 +03:00
Kalle Olavi Niemitalo
6e616e4f93 1008: Remove assertion from init_http_connection_info().
As the comment near the end of this function says, conn->info is
already non-NULL if a HTTPS proxy is being used, and the code in fact
correctly frees the previous info.  So there is no need to assert its
nonexistence.  I added that bug on 2008-05-22, in commit 291a913d1e.
2008-05-25 22:40:27 +03:00
Kalle Olavi Niemitalo
7a72a685e5 1008: Centralize random numbers.
If ELinks is being linked with SSL library, use its random number
generator.

Otherwise, try /dev/urandom and /dev/prandom.  If they do not work,
fall back to rand(), calling srand() only once.  This fallback is
mostly interesting for the Hurd and Microsoft Windows.

BitTorrent piece selection and dom/test/html-mangle.c still use rand()
(but not srand()) directly.  Those would not benefit from being
unpredictable, I think.
2008-05-25 18:44:21 +03:00