1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-29 03:17:53 -04:00
Commit Graph

108 Commits

Author SHA1 Message Date
sgerwk
153ea907a8 also pass the uri as %u to external handlers 2020-07-25 13:29:47 +02:00
Witold Filipczyk
3d96b0d7d7 Revert "Compile with C++."
This reverts commit 4f4df33638.
2019-04-21 12:27:40 +02:00
Witold Filipczyk
4f4df33638 Compile with C++.
Weak points:
- alignof
- js problems

Todo:
- make js work with C++ and mozjs-17
- then mozjs-24
- then mozjs-52
- then mozjs-60
- decrease number of warnings
2019-02-17 20:46:16 +01:00
Witold Filipczyk
8cf00fa61c delete -> delete_ for C++ compatibility 2016-04-20 18:57:32 +02:00
Witold Filipczyk
67673f5fe5 new -> new_ for C++ compatibility 2016-04-20 18:42:22 +02:00
Miciah Dashiel Butler Masters
e37caa01ec exec_later: use mem_calloc instead of calloc
Before this change, exec_later allocates memory for the struct exec_mailcap
structure using calloc.  However, the memory is freed in
exec_mailcap_command using mem_free.  Change exec_later to use mem_calloc
instead of calloc.

Unless CONFIG_FASTMEM is used, mem_free expects to find debugging metadata
that only the mem_alloc family of functions store, and thus using mem_free
on the memory allocated using calloc causes a crash.
2011-11-15 20:14:14 +00:00
Witold Filipczyk
a27e7d95ee Do not delete temporary files of external handlers. 2010-07-31 21:15:12 +02:00
Witold Filipczyk
6c7fbaeeaa Unification of protocol handler names. 2010-07-27 10:07:52 +02:00
Witold Filipczyk
1f98df36a6 copiousoutput: Temporary file is deleted by /bin/rm -f
added with ; at the of the command.

I commented also the line with file_download->delete = 0 because
it left temporary files.
2010-07-25 14:40:19 +02:00
Witold Filipczyk
7dfb20d11f Handle mailcap's copiousoutput without an external pager.
I tested it only on local PDFs.
I don't know if temporary files are deleted or not.
2010-07-24 17:07:18 +02:00
Kalle Olavi Niemitalo
ef548e5728 Merge branch 'elinks-0.12'
Conflicts:
	src/session/download.c
	src/session/download.h
	src/viewer/text/view.c
2009-07-24 18:32:25 +03:00
Kalle Olavi Niemitalo
db128fecd9 download: Add DOWNLOAD_EXTERNAL flag
Like in ELinks 0.13.GIT commit b3cfede1c1
made on 2007-11-07, only with more comments and a bit different names.
2009-07-24 18:09:59 +03:00
Kalle Olavi Niemitalo
a2c8dc8c61 download: Rename download_resume to download_flags
Bring the code closer to ELinks 0.13.GIT commit
71ccbe0f8d made on 2007-11-07.
Don't define a separate download_flags_T typedef though,
because Doxygen generates nicer links if the enum is used directly.
2009-07-24 17:10:35 +03:00
Kalle Olavi Niemitalo
ce89947fcf download: Use add_dlg_checkbox 2009-07-23 21:25:48 +03:00
Kalle Olavi Niemitalo
53c19e5b66 Bug 770: Comment updates
Since commit b7d03f9b04 on 2009-07-19,
lun_resume() no longer assumes that data points to struct cdf_hop.
2009-07-21 03:28:29 +03:00
Kalle Olavi Niemitalo
4067e54727 lookup_unique_name: Handle NULL from msg_box
If msg_box() runs out of memory, it returns NULL.  In this case,
the done_handler_T callbacks of the buttons will not be called.  So
lookup_unique_name() must instead free the struct lun_hop on its own.
2009-07-21 02:07:10 +03:00
Kalle Olavi Niemitalo
b80c0e8a0d lookup_unique_name: Remove always true condition
Remove the stracpy(ofile) call that could never be executed.
This removes the need to handle errors from that call,
and makes it clear that lun_hop->file need not be separately freed
if an error occurs in lookup_unique_name().
2009-07-21 01:09:37 +03:00
Kalle Olavi Niemitalo
71dfd47dcb lookup_unique_name: Merge error handling 2009-07-21 00:57:17 +03:00
Kalle Olavi Niemitalo
f815d27835 lookup_unique_name: Handle NULL from expand_tilde
expand_tilde() returns NULL if out of memory.
Make lookup_unique_name() handle that.
2009-07-21 00:50:54 +03:00
Kalle Olavi Niemitalo
89c7e57890 Bug 770: Don't close fd when resuming download
I added this bug last night.  continue_download_do() passed the
file descriptor to transform_codw_to_cmdw(), which saved it, but
continue_download_do() then closed it.
2009-07-19 13:44:01 +03:00
Kalle Olavi Niemitalo
075171c2c8 Bug 770: Shorten lifetime of session.download_uri
In common_download(), move session.download_uri to the new member
cmdw_hop.download_uri, which common_download_do() then reads.  This
shields the download request against possible session.download_uri
changes made for other downloads.  And transform_codw_to_cmdw() no
longer needs to touch session.download_uri at all, solving a FIXME.
2009-07-19 04:06:32 +03:00
Kalle Olavi Niemitalo
b7d03f9b04 Bug 770: Move codw->cmdw transform to outer layer
Commit ff136e5116 on 2006-07-16 made
lun_resume() check if cdf_hop->data points to struct codw_hop,
and transform that to struct cmdw_hop if so.  Move the transform
into a separate function called from continue_download_do().
This way, the structures used with create_download_file() no longer
need to begin with int magic.
2009-07-19 04:06:32 +03:00
Kalle Olavi Niemitalo
2f04a38c6f Bug 770: Fix URI leak in lun_resume
To reproduce:
- Configure with --enable-debug.
- Go to http://elinks.cz/
- Set the cursor on the "About" link and press d to download,
- ELinks asks where to save the file.  Cancel that with Esc.
  This leaves session.download_uri != NULL.
- Go to /etc/passwd
- ELinks asks what to do with the file.  Choose to download.
- ELinks asks where to save the file.  Type the name of a new file
  and press Enter.
- Again go to /etc/passwd
- ELinks asks what to do with the file.  Choose to download.
- ELinks asks where to save the file.  Type the same name as before
  and press Enter.
- ELinks asks whether to resume or overwrite.  Choose to resume.
  This changes session.download_uri and leaks the original URI.
- Quit ELinks.  It reports memory leaks:

0x88936d8:28 @ alloc'd at /home/Kalle/src/elinks-0.12/src/util/hash.c:89
0x88dac00:95 @ alloc'd at /home/Kalle/src/elinks-0.12/src/protocol/uri.c:1551
0x88c33a8:4104 @ alloc'd at /home/Kalle/src/elinks-0.12/src/util/hash.c:41

This commit fixes the leak, but it's still a bug that lun_resume() can
replace the session.download_uri that will be used by another pending
download.  In particular, this might happen if the user first presses
d to download, and then while ELinks is asking for the file name, a
web script changes window.location to a different URI and that causes
ELinks to ask what to do with the file.  So I'm leaving the FIXME
comment in for now.
2009-07-19 04:06:32 +03:00
Kalle Olavi Niemitalo
38d7bffced Bug 770: Document session.download_uri 2009-07-19 04:06:25 +03:00
Kalle Olavi Niemitalo
266d4df2d2 Fix file descriptor leaks if init_file_download fails
If init_file_download() succeeds (returning non-NULL), it saves the
file descriptor to file_download->handle, whence abort_download() will
close it.  However, if init_file_download() fails, the caller is
responsible of closing the file, something common_download_do() and
continue_download_do() failed to do.  There was no problem with
bittorrent_download() because that uses -1 as the fd.
2009-07-19 04:04:02 +03:00
Kalle Olavi Niemitalo
c7b4d5de97 Fix file name leaks if init_file_download fails
If init_file_download() succeeds (returning non-NULL), it saves the
file-name pointer to file_download->file, whence abort_download() will
free it.  However, if init_file_download() fails, the caller is
responsible of freeing the name.  bittorrent_download() already did so
but common_download_do() and continue_download_do() didn't.
2009-07-19 04:03:49 +03:00
Kalle Olavi Niemitalo
519284654b Typo fix 2009-07-18 18:09:36 +03:00
Kalle Olavi Niemitalo
34bb3c4d95 More comments about type-query callbacks 2009-07-18 02:00:44 +03:00
Kalle Olavi Niemitalo
9f217ba897 Add typedefs for type_query-related callbacks
Doxygen isn't too good at documenting the parameters of a callback
within the documentation of a parameter that points to the callback.
A typedef provides a better place to document the parameters.
2009-07-18 00:09:08 +03:00
Kalle Olavi Niemitalo
b427a4f159 Small Doxygen fixes 2009-07-17 23:58:38 +03:00
Kalle Olavi Niemitalo
dfe6d81683 Add @relates markup for Doxygen 2009-07-17 17:07:12 +03:00
Kalle Olavi Niemitalo
d41fd043c6 Add comments about struct type_query and related 2009-07-17 14:10:36 +03:00
Kalle Olavi Niemitalo
6032bc730a Disable resuming download of formatted document
If the user chose File -> Save formatted document and typed the name
of an existing file, ELinks offered to resume downloading the file.
There are a few problems with that:

* save_formatted_finish does not actually support resuming.  It would
  instead overwrite the beginning of the file and not truncate it.

* When save_formatted calls create_download_file, cdf_hop->data
  ends up pointing to struct document.  If the user then chooses to
  resume, lun_resume would read *(int *)cdf_hop->data, hoping to
  get cmdw_hop.magic or codw_hop.magic.  struct document does not
  begin with any such magic value.

* Because ELinks already has the formatted document in memory,
  resuming saves neither time nor I/O.

So don't show the "Resume download of the original file" button in
this situation.
2009-07-14 10:27:09 +03:00
Witold Filipczyk
ba70d61051 762: Instead of setting a bare pointer for task.target.frame always
use the dynamically allocated value. null_or_stracpy and mem_free_set
macros are used. Slower, but safer.
2009-01-01 22:06:59 +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
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
75302f8e62 Merge branch 'elinks-0.12' into elinks-0.13
Conflicts:

	NEWS
2008-10-03 10:55:11 +03:00
Kalle Olavi Niemitalo
4c2ddac289 Bug 1053: Fix crash when download ends.
ELinks attempted to display a message box on file_download.term, but
it had already closed that terminal and freed the struct terminal.  To
fix this, reset file_download.term pointers to NULL when the terminal
is about to be destroyed.  Also, assert in download_data_store() that
file_download.term is either NULL or in the global "terminals" list.

Reported by أحمد المحمودي.
(cherry picked from commit 6e2476ea4d)
2008-10-03 00:18:41 +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
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
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
eb8bbc9286 Revert "Copiousoutput part II. To be continued ..."
I am reverting all copiousoutput support because of bug 917.
This reverts commit f6115e65ec.

Conflicts:

	src/session/download.h: type_query.cgi, and Doxygen comments.
2008-06-15 14:38:48 +03:00
Kalle Olavi Niemitalo
196c3a8134 Revert "int_min instead of int_max. Valgrind said: invalid read"
I am reverting all copiousoutput support because of bug 917.
This reverts commit a2c12d7653.

Conflicts:

	src/session/download.c: The int_min vs. int_max change had
	  already been obsoleted by using safe_strncpy instead,
	  in commit efcd6c9758 for bug 896 on 2007-07-24.
	  Also, TERM_EXEC_FG and TERM_EXEC_BG had been added.
2008-06-15 14:31:17 +03:00
Kalle Olavi Niemitalo
6e0d4cf4bf Revert "Copiousoutput final stage. I doubt that /dev/fd/%d is portable. It works"
I am reverting all copiousoutput support because of bug 917.
This reverts commit 6ead4e9c65.

Conflicts:

	src/session/download.c: TERM_EXEC_FG and TERM_EXEC_BG had been
	  added after the original commit.
2008-06-15 14:21:55 +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
01dd1b3b65 Revert "When prompting a program for copiousoutput don't show the block checkbox"
I am reverting all copiousoutput support because of bug 917.
This reverts commit 0c2ce62459.
2008-06-15 14:05:55 +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
Miciah Dashiel Butler Masters
9e04b0ec8c Fix bug 944: avoid duplicate type-query handlers
Previously, init_type_query would check to make sure that it doesn't create a
duplicate type query and would return NULL if it otherwise would create a
duplicate.  Then setup_download_handler would return 0 to do_move.

This patch changes setup_download_handler to return 1 to do_move in this
situation so that do_move stops trying to load the document.

This avoid a crash when loading twice the same file in the same tab when
loading the file opens a type query.
2008-05-11 15:42:21 +00:00