1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-19 01:36:33 -04:00
Commit Graph

2289 Commits

Author SHA1 Message Date
Kalle Olavi Niemitalo
6d7b904fe3 Don't overcount in utf8_step_forward
Reported by witekfl.
2009-05-27 01:11:02 +03:00
Witold Filipczyk
68ccb4513d bug 765: If set download->callback set also download->data.
In the task.c line 517 there is:
	if (is_in_progress_state((*download_p)->state)) {
		if (have_location(ses))
			*download_p = &cur_loc(ses)->download;
			^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here the download was changed. download->data and download->callback
were NULL after the assignment, but later in loading_callback
only download->callback had new value. download->data was still NULL.
2009-05-27 01:11:02 +03:00
Kalle Olavi Niemitalo
0c756fc3e8 TRE: Check for 32-bit wchar_t at configure time
This check used to be in src/elinks.h.  Move it to configure.in so
that (1) the result can be logged and (2) ELinks won't even link with
TRE if wchar_t prevents its use.

Also, rename HAVE_TRE_REGEX_H to CONFIG_TRE, to reflect that it is not
always defined if the header exists.
2009-05-21 17:22:12 +03:00
Witold Filipczyk
387aeac953 No segfault
At the end of the destroy_vs there two assignments vs->doc_view->vs = NULL and
vs->doc_view = NULL. In the setup_session the copy_vs left the vs "unbound"
with any variable. At least one of these two is wrong.
2009-05-05 20:44:07 +03:00
Kalle Olavi Niemitalo
a91a08f82b Named constants in terminal option defaults
When setting up default values for terminal options, use named
constants like TERM_VT100 or COLOR_MODE_16, rather than plain integers
like 1.  This is just to make the source code easier to read and
perhaps more resistant to future bugs.  The binary should not change.
2009-04-19 20:32:37 +03:00
Kalle Olavi Niemitalo
5e0032551b Fix out-of-memory crash in globhist
If globhist_simple_search ran out of memory in stracpy(search_url), it
could leave gh_last_searched_title pointing to freed memory and cause
a crash in the next call.  Fix by not freeing gh_last_searched_title.
It is then possible to have gh_last_searched_title and
gh_last_searched_url pointing to strings from different searches;
but that was already possible if stracpy(search_title) failed.

Because this bug occurs only in out-of-memory situations and I don't
think ELinks in general has been properly tested in those, the fix is
perhaps not worth mentioning in NEWS and backporting to elinks-0.11.
2009-04-19 20:25:37 +03:00
Kalle Olavi Niemitalo
b4567b402b Bug 1071: Add precautionary assertions and recovery 2009-04-05 20:59:41 +03:00
Kalle Olavi Niemitalo
b7f45ca80b Bug 1071: Add NULL check in get_dom_node_list_index
If the parent parameter of get_dom_node_list_index referred to a node
that did not have children, then get_dom_node_list called by it could
return the address of a null pointer, and get_dom_node_list_index would
then pass that null pointer to get_dom_node_list_pos, which would crash.
That would be the same kind of crash as the one in get_dom_node_child.
It never happened in practice though: because all calls are in the form
get_dom_node_list_index(node->parent, node), the list must contain at
least the given node, and the pointer cannot be null.  The documentation
of get_dom_node_list_index allows arbitrary nodes as arguments however,
so it's best to add a check.
2009-04-04 22:41:43 +03:00
Kalle Olavi Niemitalo
0c1a27ee99 Bug 1071: Document get_dom_node_value return values 2009-04-04 22:38:56 +03:00
Kalle Olavi Niemitalo
8465b19d0c Bug 1071: Fix null-ptr crash in get_dom_node_child
struct dom_node contains a union that contains various structs that
have members of type struct dom_node * in them.
get_dom_node_list_by_type returns the address (struct dom_node **) of
one of those members, or NULL.  However the member itself can also be
NULL if no nodes have been added to the list and the list has thus not
yet been allocated.  (add_to_dom_node_list lazily allocates the lists.)
get_dom_node_child did not expect a null pointer there and crashed, as
shown in bug 1071.  Fix by adding a check so that it treats a NULL list
as an empty list.
2009-04-04 21:56:53 +03:00
Kalle Olavi Niemitalo
d7d18e4e43 bug 1047: inline functions C99 conformance
C99 6.7.4p3 and 6.7.4p6 set some constraints on what can be done in
inline functions and how they can be declared.  In particular, any
function declared inline must also be defined in the same translation
unit.  To comply with that, remove inline specifiers from function
declarations in header files when the functions are not also defined
in those header files.

Sun Studio 11 on Solaris 9 is stricter than C99 and does not allow
references to static identifiers in extern inline functions.  Make the
configure script detect this and define NONSTATIC_INLINE accordingly
in config.h.  Then use that in the definitions of all non-static
inline functions.

Document the restrictions and this scheme in doc/hacking.txt.
2009-03-28 20:15:08 +02:00
Kalle Olavi Niemitalo
5a43c55c9e Rewrap lines in option documentation.
Documentation strings of most options used to contain a "\n" at the
end of each source line.  When the option manager displayed these
strings, it treated each "\n" as a hard newline.  On 80x24 terminals
however, the option description window has only 60 columes available
for the text (with the default setup.h), and the hard newlines were
further apart, so the option manager wrapped the text a second time,
resulting in rather ugly output where long lones are interleaved with
short ones.  This could also cause the text to take up too much
vertical space and not fit in the window.

Replace most of those hard newlines with spaces so that the option
manager (or perhaps BFU) will take care of the wrapping.  At the same
time, rewrap the strings in source code so that the source lines are
at most 79 columns wide.

In some options though, there is a list of possible values and their
meanings.  In those lists, if the description of one value does not
fit in one line, then continuation lines should be indented.  The
option manager and BFU are not currently able to do that.  So, keep
the hard newlines in those lists, but rewrap them to 60 columns so
that they are less likely to require further wrapping at runtime.
2009-03-08 15:18:10 +02:00
Kalle Olavi Niemitalo
a277c0ad3b Wrap option descriptions in --config-help, --long-help 2009-03-08 13:29:51 +02:00
Kalle Olavi Niemitalo
bd5d3a173f Add wrap_option_desc() in conf.c, still static
Move the description wrapping code from smart_config_output_fn()
to a separate function wrap_option_desc() so that --config-help
can soon use it too.
2009-03-08 13:29:51 +02:00
Kalle Olavi Niemitalo
8ad32809e1 bug 153, 1066: Fix search in bookmark manager.
test_search() was supposed to compare bookmark titles with
strcasestr(), but in commit 311d95358d
"bug 153, 1066: Convert bookmarks to/from UTF-8 when searching."
on 2009-02-08, I inadvertently changed that to strcasecmp(), even
while adding a comment about why strcasestr() is needed.  strcasestr()
returns non-NULL if the strings match, and strcasecmp() returns
nonzero if they differ, so the search didn't work at all.
2009-03-01 09:21:29 +02:00
Kalle Olavi Niemitalo
1487d206db Bug 1069: Revert "1031: JS_SetErrorReporter only once per JSRuntime."
This reverts commit b94657869b.
I don't know where I got the idea that JS_SetErrorReporter affects the
entire JSRuntime, rather than only the provided JSContext.  The people
on #jsapi say it has never worked that way.
2009-02-26 22:56:33 +02:00
Miciah Dashiel Butler Masters
e9370fe5b9 Comment the last change 2009-02-25 01:54:36 +00:00
Miciah Dashiel Butler Masters
f11b2a8f97 utf8_to_jsstring: Don't free mem handed over to JS
In utf8_to_jsstring, do not free the string that is passed to
JS_NewUCString if the latter is successful; if it is, SpiderMonkey
handles the memory from then on.

Use libc routines instead of ELinks's routines to allocate and free the
string so that ELinks's memory debugging code does not try to keep track
of it after it has been handed to SpiderMonkey.

This commit fixes a bug introdued in
97d72d15a0.
2009-02-25 01:45:56 +00:00
Kalle Olavi Niemitalo
39707c4102 Rewrap protocol.http.compression doc to 59 columns
This makes the option manager display it much better on an 80x24
terminal.

Alternatively, the "\n" newline characters within paragraphs could
have been removed entirely.  ELinks would then have line-wrapped the
text to the appropriate width in the info window of the option
manager, but unfortunately not in --config-help.
2009-02-22 21:28:14 +02:00
Kalle Olavi Niemitalo
2a7346d371 Tone down the protocol.http.compression warning
AFAIK, all bugs in it have been fixed.  Some bugs may still be lurking
but they are more likely to get caught if compression is enabled.

I also replaced COMP_NOTE with static text because xgettext does not
support macros in the argument of N_.
(cherry picked from commit 3a9b5d091d)
2009-02-22 20:55:05 +02:00
Petr Baudis
a7f94dbbd1 Introduce protocol.http.compression knob
When disabled, no Accept-Encoding header is sent.
(cherry picked from commit d4cec950ec)

Conflicts:

	src/protocol/http/http.c
2009-02-22 20:17:53 +02:00
Miciah Dashiel Butler Masters
84259ff26a Fix crash on search-toggle-regex when RE disabled
Check the return value of get_opt_rec on "document.browse.search.regex"
before dereferencing it.  The option is not there if regular expression
support is disabled at build time.

This commit fixes a bug introduced in commit
b2d51c75ff0d6c52a4f6a2761801beb641cba3a2.
2009-02-22 04:06:51 +00:00
Witold Filipczyk
4a2fd2d964 Fallback to the raw deflate only when nothing was decompressed so far.
It lets view the site from bug 1017.
(cherry picked from commit 3131de4767)

Conflicts:

	src/protocol/http/http.c
2009-02-21 14:12:03 +01:00
Witold Filipczyk
53ab6d493e bug 1068: Decompress data when the socket is closed.
The reasons why the decompression failed:
- the server gave wrong Content-Length
- the socket was closed
2009-02-21 10:36:44 +01:00
Kalle Olavi Niemitalo
d14f65a331 bug 1067: Comments about freeing the DOM document node. 2009-02-15 04:27:39 +02:00
Kalle Olavi Niemitalo
eb820a57a6 bug 1067: Assertions and comments about done_dom_node().
In bug 1067, dom_rss_pop_document() freed a node with done_dom_node()
even though call_dom_node_callbacks() was still using that node.  This
made call_dom_node_callbacks() read a function pointer from beyond the
end of an array and call that.  Add assertions to detect out-of-range
node types, and comments to warn about the bug.
2009-02-15 03:39:00 +02:00
Witold Filipczyk
a7c2f14e6d bug 1067: the node was freed, but still used. 2009-02-12 09:48:04 +01:00
Kalle Olavi Niemitalo
7067fc7af9 Check for JS_ReportAllocationOverflow before using it.
Debian libmozjs-dev 1.9.0.4-2 has JS_ReportAllocationOverflow but
js-1.7.0 reportedly hasn't.  Check at configure time whether that
function is available.  If not, use JS_ReportOutOfMemory instead.

Reported by Witold Filipczyk.
2009-02-08 23:07:22 +02:00
Witold Filipczyk
664048098a Bug 1060: #undef HAVE_TRE_REGEX_H only in elinks.h
I didn't read the code of the tre library, but I suppose that when sizes of
wchar_t and unicode_val_T are equal it will work fine.

[ From bug 1060 attachment 508.  --KON ]
2009-02-08 18:26:22 +02:00
Witold Filipczyk
c5a7f87c43 Bug 1060: Use libtre for regexp searches.
When the user tells ELinks to search for a regexp, ELinks 0.11.0
passes the regexp to regcomp() and the formatted document to
regexec(), both in the terminal charset.  This works OK for unibyte
ASCII-compatible charsets because the regexp metacharacters are all in
the ASCII range.  And ELinks 0.11.0 doesn't support multibyte or
ASCII-incompatible (e.g. EBCDIC) charsets in terminals, so it is no
big deal if regexp searches fail in such locales.

ELinks 0.12pre1 attempts to support UTF-8 as the terminal charset if
CONFIG_UTF8 is defined.  Then, struct search contains unicode_val_T c
rather than unsigned char c, and get_srch() and add_srch_chr()
together save UTF-32 values there if the terminal charset is UTF-8.
In plain-text searches, is_in_range_plain() compares those values
directly if the search is case sensitive, or folds them to lower case
if the search is case insensitive: with towlower() if the terminal
charset is UTF-8, or with tolower() otherwise.  In regexp searches
however, get_search_region_from_search_nodes() still truncates all
values to 8 bits in order to generate the string that
search_for_pattern() then passes to regexec().  In UTF-8 locales,
regexec() expects this string to be in UTF-8 and can't make sense of
the truncated characters.  There is also a possible conflict in
regcomp() if the locale is UTF-8 but the terminal charset is not, or
vice versa.

Rejected ways of fixing the charset mismatches:

* When the terminal charset is UTF-8, recode the formatted document
  from UTF-32 to UTF-8 for regexp searching.  This would work if the
  terminal and the locale both use UTF-8, or if both use unibyte
  ASCII-compatible charsets, but not if only one of them uses UTF-8.

* Convert both the regexp and the formatted document to the charset of
  the locale, as that is what regcomp() and regexec() expect.  ELinks
  would have to somehow keep track of which bytes in the converted
  string correspond to which characters in the document; not entirely
  trivial because convert_string() can replace a single unconvertible
  character with a string of ASCII characters.  If ELinks were
  eventually changed to use iconv() for unrecognized charsets, such
  tracking would become even harder.

* Temporarily switch to a locale that uses the charset of the
  terminal.  Unfortunately, it seems there is no portable way to
  construct a name for such a locale.  It is also possible that no
  suitable locale is available; especially on Windows, whose C library
  defines MB_LEN_MAX as 2 and thus cannot support UTF-8 locales.

Instead, this commit makes ELinks do the regexp matching with regwcomp
and regwexec from the TRE library.  This way, ELinks can losslessly
recode both the pattern and the document to Unicode and rely on the
regexp code in TRE decoding them properly, regardless of locale.

There are some possible problems though:

1. ELinks stores strings as UTF-32 in arrays of unicode_val_T, but TRE
   uses wchar_t instead.  If wchar_t is UTF-16, as it is on Microsoft
   Windows, then TRE will misdecode the strings.  It wouldn't be too
   hard to make ELinks convert to UTF-16 in this case, but (a) TRE
   doesn't currently support UTF-16 either, and it seems possible that
   wchar_t-independent UTF-32 interfaces will be added to TRE; and (b)
   there seems to be little interest on using ELinks on Windows anyway.

2. The Citrus Project apparently wanted BSD to use a locale-dependent
   wchar_t: e.g. UTF-32 in some locales and an ISO 2022 derivative in
   others.  Regexp searches in ELinks now do not support the latter.

[ Adapted to elinks-0.12 from bug 1060 attachment 506.
  Commit message by me.  --KON ]
2009-02-08 18:26:22 +02:00
Kalle Olavi Niemitalo
264a66fe4d bug 153: UTF-8 bookmark.title has been fully implemented.
Mention it in NEWS too.
2009-02-08 18:26:21 +02:00
Kalle Olavi Niemitalo
311d95358d bug 153, 1066: Convert bookmarks to/from UTF-8 when searching. 2009-02-08 18:26:21 +02:00
Kalle Olavi Niemitalo
8c0fa7f09c bug 153, 1066: Convert strings to edit-bookmark dialog from UTF-8. 2009-02-08 18:26:21 +02:00
Kalle Olavi Niemitalo
5a29dbc4a1 bug 153, 1066: Convert strings to bookmark info dialog from UTF-8. 2009-02-08 18:26:20 +02:00
Kalle Olavi Niemitalo
b3acd2a5bc bug 153: Convert titles in bookmark manager from UTF-8. 2009-02-08 18:26:20 +02:00
Kalle Olavi Niemitalo
b3f9d48bba bug 153, 1066: Convert strings from add-bookmark dialogs to UTF-8.
In src/bookmarks/dialogs.c, do_add_bookmark() gets the title and URL
in the terminal charset and needs to know which one that is.  When a
bookmark is being added, save the struct terminal * to dialog.udata2
and read the charset from there.  When a bookmark is being edited,
dialog.udata2 is needed for the struct bookmark *, but there we always
have the parent struct dialog_data * in dialog.udata and can get the
terminal from that.
2009-02-08 18:26:19 +02:00
Kalle Olavi Niemitalo
b432b735e4 bug 1066: Attempt to convert -remote addBookmark(URL) to UTF-8.
Currently, it is not clear which codepage is used in struri().
Assume it is the system codepage.
2009-02-08 18:26:19 +02:00
Kalle Olavi Niemitalo
99d1269bc5 bug 153, 1066: Convert session-snapshot bookmarks to/from UTF-8.
These functions now expect or return strings in UTF-8:
delete_folder_by_name (sneak in a const, too), bookmark_terminal_tabs,
open_bookmark_folder, and get_auto_save_bookmark_foldername_utf8 (new
function).
2009-02-08 18:26:19 +02:00
Kalle Olavi Niemitalo
11acd03eb2 Use update_bookmark() in SMJS bookmark object.
When setting the title or URL of a bookmark from SMJS user scripting,
use update_bookmark() instead of writing directly to struct bookmark.
It triggers the bookmark-update event and sets the bookmarks_dirty
flag.
2009-02-08 18:26:18 +02:00
Kalle Olavi Niemitalo
97d72d15a0 bug 153, 1066: Convert properties of SMJS bookmark to/from UTF-8.
SpiderMonkey uses UTF-16 and the strings in struct bookmark are in
UTF-8.  Previously, the conversions behaved as if the strings had been
in ISO-8859-1.

SpiderMonkey also supports JS_SetCStringsAreUTF8(), which would make
the existing functions convert between UTF-16 and UTF-8, but that
effect is global so I dare not enable it yet.  Besides, I don't know
if that function works in all the SpiderMonkey versions that ELinks
claims to work with.
2009-02-08 18:26:18 +02:00
Kalle Olavi Niemitalo
03b112796d bug 153, 1066: Add codepage parameter to update_bookmark().
This also makes the bookmark-update event carry strings in UTF-8.
The only current consumer of that event is bookmark_change_hook(),
which ignores the strings, so no changes are needed there.
2009-02-08 18:26:18 +02:00
Kalle Olavi Niemitalo
73f925ce21 bug 153, 1066: Convert XBEL bookmarks to/from UTF-8.
When the file is being read, Expat provides the strings to ELinks in
UTF-8, so ELinks can put them in struct bookmark without conversions.
Make sure gettext returns any placeholder strings in UTF-8, too.
Replace '\r' with ' ' in bookmark titles and URLs.

When the file is being written, put encoding="UTF-8" in the XML
declaration, and then write out the strings from struct bookmark
without character set conversions.  Do replace some characters
with entity references though, by calling add_html_to_string().
2009-02-08 18:26:04 +02:00
Kalle Olavi Niemitalo
8c0ae2a215 bug 153, 1066: Convert ~/.elinks/bookmarks to/from UTF-8.
The ~/.elinks/bookmarks file is in the system charset,
for compatibility with earlier ELinks releases,
but internally the strings are in UTF-8.
2009-01-24 14:38:59 +02:00
Kalle Olavi Niemitalo
1cb81679f4 bug 153, 1066: Add add_bookmark_cp(). 2009-01-24 12:18:28 +02:00
Kalle Olavi Niemitalo
d1f2f8df80 bug 153, 1066: init_bookmark() and add_bookmark() expect UTF-8.
Comment changes only.
2009-01-24 12:17:48 +02:00
Kalle Olavi Niemitalo
37de386051 bug 153, 1066: Document that bookmarks should be UTF-8.
Comment changes only.
2009-01-24 12:12:45 +02:00
Kalle Olavi Niemitalo
9088f11c64 Make encode_utf8() extern even without CONFIG_UTF8.
It will soon be needed for conversions from UTF-16 to UTF-8.
2009-01-04 16:55:24 +02:00
Kalle Olavi Niemitalo
a82a5cc6d5 XBEL bug 761: Distinguish between names and values of attributes.
When ELinks is parsing an XML element in from an XBEL bookmark file,
it collects the attributes of the element to the current_node->attrs
list.  Previously, struct attributes had room for one string only:
the last element of current_node->attrs was the name of the first
attribute, and it was preceded by the value of the first attribute,
the name of the second attribute, the value of the second attribute,
and so on.  However, when get_attribute_value() was looking for a
given name, it compared the values as well.  So, if you had for
example <bookmark id="href" href="http://elinks.cz/">, then
get_attribute_value("href") would incorrectly return "href".

To fix this confusion, store values in the new member
attributes.value, rather than in attributes.name.
2009-01-04 15:15:21 +02:00
Kalle Olavi Niemitalo
30dbe6a2f8 Use get_terminal_codepage in handle_interlink_event.
This should have been in an earlier commit but I somehow missed it.

Related to bug 1064 but does not change visible behaviour yet.
2009-01-01 22:59:11 +00:00
Kalle Olavi Niemitalo
e5722ad0d9 Bug 1061: Correctly truncate UTF-8 titles in the tab bar. 2009-01-01 20:01:50 +00:00