diff options
-rw-r--r-- | dillorc | 2 | ||||
-rw-r--r-- | doc/dw-out-of-flow.doc | 41 | ||||
-rw-r--r-- | dpi/cookies.c | 7 | ||||
-rw-r--r-- | dpi/https.c | 7 | ||||
-rw-r--r-- | dw/imgrenderer.cc | 19 | ||||
-rw-r--r-- | dw/style.cc | 26 | ||||
-rw-r--r-- | dw/style.hh | 2 | ||||
-rw-r--r-- | dw/textblock.cc | 3 | ||||
-rw-r--r-- | dw/textblock_iterator.cc | 56 | ||||
-rw-r--r-- | dw/widget.cc | 25 | ||||
-rw-r--r-- | lout/container.cc | 72 | ||||
-rw-r--r-- | lout/container.hh | 42 | ||||
-rw-r--r-- | lout/unicode.cc | 20 | ||||
-rw-r--r-- | src/capi.c | 131 | ||||
-rw-r--r-- | src/cookies.h | 3 | ||||
-rw-r--r-- | src/html.cc | 4 | ||||
-rw-r--r-- | src/url.c | 11 | ||||
-rw-r--r-- | test/cookies.c | 16 |
18 files changed, 319 insertions, 168 deletions
@@ -259,7 +259,7 @@ search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # "plastic" "is inspired by the Aqua user interface on Mac OS X". # "gtk+" "is inspired by the Red Hat Bluecurve theme". # -# Once fltk-1.3.3 is released, you will be able to specify "gleam", which +# If you have fltk-1.3.3 or newer, you can specify "gleam", which # is "a sort of Clearlooks Glossy scheme". ("fltk-config --version") #theme=none # theme=gtk+ diff --git a/doc/dw-out-of-flow.doc b/doc/dw-out-of-flow.doc index 8bfcde4c..b7ebee40 100644 --- a/doc/dw-out-of-flow.doc +++ b/doc/dw-out-of-flow.doc @@ -234,45 +234,6 @@ Integration of line breaking and floats Absolute and fixed positiones ============================= -If you look at dw::OutOfFlowMgr in detail, you will find that some -work on **absolute positions** has already be done, but is -deactivated. Absolutely positioned elements will also be handled by -dw::OutOfFlowMgr, in a way transparent to dw::Textblock. Positioning -is much simpler than for floats: the complicated relation between -dw::Textblock and dw::OutOfFlowMgr (calculation of the vertical -position of floats on one hand, limiting line widths by floats on the -other hand) does not occur here. - -Since handling sizes becomes an important part for absolute positions, -the full implementation will be realized after finishing the planned -redesign of widget sizes (see \ref dw-grows). - -(One note already about the *z-index* attribute: different blocks, -represented by widgets, may overlap; *z-index* has an influence the -order in which - -1. widgets are drawn (in *ascending* order of *z-index*), and -2. mouse events are deligated to the widgets (in *descending* oder of - *z-index*). - -Something similar is already done for floats: effectively, floats have -a larger *z-index* than the textblocks in flow. (See *end* of -dw::Textblock::draw and *beginning* of -dw::Textblock::getWidgetAtPoint.) - -For a complete implementation, handling *z-index* becomes a bit more -complicated. An idea is to keep track of the minimum and maximum value -of *z-index*, and then iterating over all possible values (ascending -for drawing, descending for event handling), handling only widgets -with a specific *z-index* in one iteration.) - -There are currently no plans for an implementation of **fixed -positions** soon. These problems have to be considered: - -- Generally attaching dillo widgets to the viewport, not the canvas; - this is also required for the implementation of - *background-attachment*, see \ref dw-images-and-backgrounds. -- To which containing block are elements with fixed position related? - To the same as floats and absolutely positioned? +To be documented. */
\ No newline at end of file diff --git a/dpi/cookies.c b/dpi/cookies.c index 6c5e958e..b858bd53 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -1042,14 +1042,13 @@ static uint_t Cookies_internal_dots_required(const char *host) if (tld_len > 0) { /* These TLDs were chosen by examining the current publicsuffix list - * in February 2014 and picking out those where it was simplest for + * in October 2014 and picking out those where it was simplest for * them to describe the situation by beginning with a "*.[tld]" rule * or every rule was "[something].[tld]". */ - const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk", + const char *const tlds[] = {"bd","bn","ck","cy","er","fj","fk", "gu","il","jm","ke","kh","kw","mm","mz", - "ni","np","nz","pg","tr","uk","ye","za", - "zm","zw"}; + "ni","np","pg","ye","za","zm","zw"}; uint_t i, tld_num = sizeof(tlds) / sizeof(tlds[0]); for (i = 0; i < tld_num; i++) { diff --git a/dpi/https.c b/dpi/https.c index f0b4ec89..da75b9e8 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -156,11 +156,12 @@ static void yes_ssl_support(void) } } - /* Do not use the obsolete insecure SSLv2 protocol, and everyone disabled - * TLS compression when the CRIME exploit became widely known in 2012. + /* SSL2 has been known to be insecure forever, disabling SSL3 is in response + * to POODLE, and disabling compression is in response to CRIME. */ if (exit_error == 0){ - SSL_CTX_set_options(ssl_context, SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION); + SSL_CTX_set_options(ssl_context, + SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION); } /*Set directory to load certificates from*/ diff --git a/dw/imgrenderer.cc b/dw/imgrenderer.cc index 285a8dcd..14806ea2 100644 --- a/dw/imgrenderer.cc +++ b/dw/imgrenderer.cc @@ -1,3 +1,22 @@ +/* + * Dillo Widget + * + * Copyright 2013 Sebastian Geerken <sgeerken@dillo.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "core.hh" namespace dw { diff --git a/dw/style.cc b/dw/style.cc index 830613fa..32a33a9e 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -1208,18 +1208,26 @@ void drawBorder (View *view, Layout *layout, Rectangle *area, * * Otherwise, the caller should not try to increase the performance by * doing some tests before; this is all done in this method. + * + * "bgColor" is passes implicitly. For non-inversed drawing, + * style->backgroundColor may simply used. However, when drawing is + * inversed, and style->backgroundColor is undefined (NULL), a + * background color defined higher in the hierarchy (which is not + * accessable here) must be used. + * + * (Background *images* are never drawn inverse.) */ void drawBackground (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef, - Style *style, bool inverse, bool atTop) + Style *style, Color *bgColor, bool inverse, bool atTop) { - bool bgColor = style->backgroundColor != NULL && + bool hasBgColor = bgColor != NULL && // The test for background colors is rather simple, since only the color // has to be compared, ... - (!atTop || layout->getBgColor () != style->backgroundColor); - bool bgImage = (style->backgroundImage != NULL && - style->backgroundImage->getImgbufSrc() != NULL) && + (!atTop || layout->getBgColor () != bgColor); + bool hasBgImage = (style->backgroundImage != NULL && + style->backgroundImage->getImgbufSrc() != NULL) && // ... but for backgrounds, it would be rather complicated. To handle the // two cases (normal HTML in a viewport, where the layout background // image is set, and contents of <button> within a flat view, where the @@ -1233,7 +1241,7 @@ void drawBackground (View *view, Layout *layout, Rectangle *area, // necessary to draw the background if background color and image // are not set (NULL), i. e. shining through. - if (bgColor || bgImage) { + if (hasBgColor || hasBgImage) { Rectangle bgArea, intersection; bgArea.x = x; bgArea.y = y; @@ -1241,14 +1249,14 @@ void drawBackground (View *view, Layout *layout, Rectangle *area, bgArea.height = height; if (area->intersectsWith (&bgArea, &intersection)) { - if (bgColor) - view->drawRectangle (style->backgroundColor, + if (hasBgColor) + view->drawRectangle (bgColor, inverse ? Color::SHADING_INVERSE : Color::SHADING_NORMAL, true, intersection.x, intersection.y, intersection.width, intersection.height); - if (bgImage) + if (hasBgImage) drawBackgroundImage (view, style->backgroundImage, style->backgroundRepeat, style->backgroundAttachment, diff --git a/dw/style.hh b/dw/style.hh index 43fff0a1..12ca1664 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -903,7 +903,7 @@ void drawBorder (View *view, Layout *layout, Rectangle *area, void drawBackground (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef, - Style *style, bool inverse, bool atTop); + Style *style, Color *bgColor, bool inverse, bool atTop); void drawBackgroundImage (View *view, StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, diff --git a/dw/textblock.cc b/dw/textblock.cc index 18303951..d88b411f 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -3129,7 +3129,8 @@ Textblock *Textblock::getTextblockForLine (Line *line) Textblock *Textblock::getTextblockForLine (int lineNo) { - int firstWord = lineNo == 0 ? 0 :lines->getRef(lineNo - 1)->lastWord + 1; + // Can also be used for a line not yet existing. + int firstWord = lineNo == 0 ? 0 : lines->getRef(lineNo - 1)->lastWord + 1; int lastWord = lineNo < lines->size() ? lines->getRef(lineNo)->lastWord : words->size() - 1; return getTextblockForLine (firstWord, lastWord); diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc index 8da692d6..95e2ce65 100644 --- a/dw/textblock_iterator.cc +++ b/dw/textblock_iterator.cc @@ -188,15 +188,54 @@ void Textblock::TextblockIterator::getAllocation (int start, int end, { if (inFlow ()) { Textblock *textblock = (Textblock*)getWidget(); - int index = getInFlowIndex (), - lineIndex = textblock->findLineOfWord (index); - Line *line = textblock->lines->getRef (lineIndex); - Word *word = textblock->words->getRef (index); - allocation->x = - textblock->allocation.x + line->textOffset; + int index = getInFlowIndex (); + Word *word = textblock->words->getRef (index); + int firstWordOfLine, textOffset, lineYOffsetCanvas, lineBorderAscent; + + int lineIndex = textblock->findLineOfWord (index); + + // It may be that the line does not exist yet. + if (lineIndex != -1) { + // Line exists: simple. + Line *line = textblock->lines->getRef (lineIndex); + firstWordOfLine = line->firstWord; + textOffset = line->textOffset; + lineYOffsetCanvas = textblock->lineYOffsetCanvas (line); + lineBorderAscent = line->borderAscent; + } else { + // Line does not exist. Calculate the values in a similar way as in + // Textblock::addLine(). + Line *prevLine = textblock->lines->size () > 0 ? + textblock->lines->getLastRef () : NULL; + firstWordOfLine = prevLine ? prevLine->lastWord + 1 : 0; + + // The variable textOffset, defined below, is what Line::leftOffset + // will be for the next line; Line::textOffset itself cannot be + // calculated before the line is complete. + bool regardBorder = + textblock->mustBorderBeRegarded (textblock->lines->size ()); + textOffset = + misc::max (regardBorder ? textblock->newLineLeftBorder : 0, + textblock->boxOffsetX () + textblock->leftInnerPadding + + (textblock->lines->size () == 0 ? + textblock->line1OffsetEff : 0)); + + lineYOffsetCanvas = textblock->yOffsetOfLineToBeCreated (); + + lineBorderAscent = 0; + for (int i = firstWordOfLine; i < textblock->words->size (); i++) { + Word *w = textblock->words->getRef (i); + int borderAscent = + w->content.type == core::Content::WIDGET_IN_FLOW ? + w->size.ascent - w->content.widget->getStyle()->margin.top : + w->size.ascent; + lineBorderAscent = misc::max (lineBorderAscent, borderAscent); + } + } - for (int i = line->firstWord; i < index; i++) { + allocation->x = textblock->allocation.x + textOffset; + for (int i = firstWordOfLine; i < index; i++) { Word *w = textblock->words->getRef(i); allocation->x += w->size.width + w->effSpace; } @@ -208,8 +247,7 @@ void Textblock::TextblockIterator::getAllocation (int start, int end, && word->content.text[start] == 0); } - allocation->y = textblock->lineYOffsetCanvas (line) + line->borderAscent - - word->size.ascent; + allocation->y = lineYOffsetCanvas + lineBorderAscent - word->size.ascent; allocation->width = word->size.width; if (word->content.type == core::Content::TEXT) { diff --git a/dw/widget.cc b/dw/widget.cc index 4c1fb896..9c517f24 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -1422,6 +1422,10 @@ void Widget::drawBox (View *view, style::Style *style, Rectangle *area, // does not define what here is called "reference area". To make it look // smoothly, the widget padding box is used. + // TODO Handle inverse drawing the same way as in drawWidgetBox? + // Maybe this method (drawBox) is anyway obsolete when extraSpace + // is fully supported (as here, in the "dillo_grows" repository). + int xPad, yPad, widthPad, heightPad; getPaddingArea (&xPad, &yPad, &widthPad, &heightPad); style::drawBackground @@ -1432,7 +1436,8 @@ void Widget::drawBox (View *view, style::Style *style, Rectangle *area, - style->margin.right - style->borderWidth.right, height - style->margin.top - style->borderWidth.top - style->margin.bottom - style->borderWidth.bottom, - xPad, yPad, widthPad, heightPad, style, inverse, false); + xPad, yPad, widthPad, heightPad, style, style->backgroundColor, + inverse, false); } /** @@ -1456,10 +1461,26 @@ void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse) int xPad, yPad, widthPad, heightPad; getPaddingArea (&xPad, &yPad, &widthPad, &heightPad); + + style::Color *bgColor; + if (inverse && style->backgroundColor == NULL) { + // See style::drawBackground: for inverse drawing, we need a + // defined background color. Search through ancestors. + Widget *w = this; + while (w != NULL && w->style->backgroundColor == NULL) + w = w->parent; + + if (w != NULL && w->style->backgroundColor != NULL) + bgColor = w->style->backgroundColor; + else + bgColor = layout->getBgColor (); + } else + bgColor = style->backgroundColor; + style::drawBackground (view, layout, &canvasArea, xPad, yPad, widthPad, heightPad, xPad, yPad, widthPad, heightPad, - style, inverse, parent == NULL); + style, bgColor, inverse, parent == NULL); } /* diff --git a/lout/container.cc b/lout/container.cc index 2dd56255..366a58fa 100644 --- a/lout/container.cc +++ b/lout/container.cc @@ -120,6 +120,11 @@ Vector::~Vector() DBG_OBJ_DELETE (); } +int Vector::size () +{ + return numElements; +} + void Vector::put(Object *newElement, int newPos) { if (newPos == -1) @@ -296,6 +301,32 @@ List::~List() clear(); } +int List::size () +{ + return numElements; +} + +bool List::equals(Object *other) +{ + List *otherList = (List*)other; + Node *node1 = first, *node2 = otherList->first; + while (node1 != NULL && node2 != NULL ) { + if (!node1->object->equals (node2->object)) + return false; + node1 = node1->next; + node2 = node2->next; + } + return node1 == NULL && node2 == NULL; +} + +int List::hashValue() +{ + int h = 0; + for (Node *node = first; node; node = node->next) + h = h ^ node->object->hashValue (); + return h; +} + void List::clear() { while (first) { @@ -325,6 +356,28 @@ void List::append(Object *element) numElements++; } +bool List::insertBefore(object::Object *beforeThis, object::Object *neew) +{ + Node *beforeCur, *cur; + + for (beforeCur = NULL, cur = first; cur; beforeCur = cur, cur = cur->next) { + if (cur->object == beforeThis) { + Node *newNode = new Node; + newNode->next = cur; + newNode->object = neew; + + if (beforeCur) + beforeCur->next = newNode; + else + first = newNode; + + numElements++; + return true; + } + } + + return false; +} bool List::remove0(Object *element, bool compare, bool doNotDeleteAtAll) { @@ -392,6 +445,8 @@ HashSet::HashSet(bool ownerOfObjects, int tableSize) table = new Node*[tableSize]; for (int i = 0; i < tableSize; i++) table[i] = NULL; + + numElements = 0; } HashSet::~HashSet() @@ -419,6 +474,11 @@ HashSet::~HashSet() delete[] table; } +int HashSet::size () +{ + return numElements; +} + HashSet::Node *HashSet::createNode() { return new Node; @@ -447,13 +507,15 @@ HashSet::Node *HashSet::insertNode(Object *object) { // Look whether object is already contained. Node *node = findNode(object); - if (node) + if (node) { clearNode(node); - else { + numElements--; + } else { int h = calcHashValue(object); node = createNode (); node->next = table[h]; table[h] = node; + numElements++; } node->object = object; @@ -491,6 +553,7 @@ bool HashSet::remove(Object *object) clearNode (cur); delete cur; + numElements--; return true; } @@ -662,6 +725,11 @@ Stack::~Stack() pop (); } +int Stack::size () +{ + return numElements; +} + void Stack::push (object::Object *object) { Node *newTop = new Node (); diff --git a/lout/container.hh b/lout/container.hh index a7f01732..f8c22439 100644 --- a/lout/container.hh +++ b/lout/container.hh @@ -93,6 +93,7 @@ class Collection: public Collection0 public: void intoStringBuffer(misc::StringBuffer *sb); inline Iterator iterator() { Iterator it(createIterator()); return it; } + virtual int size() = 0; }; @@ -128,6 +129,8 @@ public: Vector(int initSize, bool ownerOfObjects); ~Vector(); + int size(); + void put(object::Object *newElement, int newPos = -1); void insert(object::Object *newElement, int pos); @@ -137,15 +140,15 @@ public: * Notice that insertion is not very efficient, unless the position * is rather at the end. */ - inline void insertSorted(object::Object *newElement, - object::Comparator *comparator = - &object::standardComparator) - { insert (newElement, bsearch (newElement, false, comparator)); } + inline int insertSorted(object::Object *newElement, + object::Comparator *comparator = + &object::standardComparator) + { int pos = bsearch (newElement, false, comparator); + insert (newElement, pos); return pos; } void remove(int pos); inline object::Object *get(int pos) const { return (pos >= 0 && pos < numElements) ? array[pos] : NULL; } - inline int size() { return numElements; } void clear(); void sort(object::Comparator *comparator = &object::standardComparator); int bsearch(Object *key, bool mustExist, int start, int end, @@ -195,8 +198,14 @@ public: List(bool ownerOfObjects); ~List(); + bool equals(Object *other); + int hashValue(); + + int size (); + void clear(); void append(object::Object *element); + bool insertBefore(object::Object *beforeThis, object::Object *neew); inline bool removeRef(object::Object *element) { return remove0(element, false, false); } inline bool remove(object::Object *element) @@ -225,7 +234,7 @@ protected: }; Node **table; - int tableSize; + int tableSize, numElements; bool ownerOfObjects; inline int calcHashValue(object::Object *object) const @@ -261,6 +270,8 @@ public: HashSet(bool ownerOfObjects, int tableSize = 251); ~HashSet(); + int size (); + void put (object::Object *object); bool contains (object::Object *key) const; bool remove (object::Object *key); @@ -334,6 +345,8 @@ public: Stack (bool ownerOfObjects); ~Stack(); + int size (); + void push (object::Object *object); void pushUnder (object::Object *object); inline object::Object *getTop () const { return top ? top->object : NULL; } @@ -393,11 +406,16 @@ public: Collection () { this->base = NULL; } ~Collection () { if (this->base) delete this->base; } + bool equals(Object *other) + { return this->base->equals (((Collection<T>*)other)->base); } + + int hashValue() { return this->base->hashValue (); } + void intoStringBuffer(misc::StringBuffer *sb) { this->base->intoStringBuffer(sb); } - inline Iterator<T> iterator() { Iterator<T> it; it.base = this->base->iterator(); return it; } + inline int size() { return this->base->size (); } }; @@ -414,14 +432,14 @@ public: { ((untyped::Vector*)this->base)->put(newElement, newPos); } inline void insert(T *newElement, int pos) { ((untyped::Vector*)this->base)->insert(newElement, pos); } - inline void insertSorted(T *newElement, + inline bool insertSorted(T *newElement, object::Comparator *comparator = &object::standardComparator) - { ((untyped::Vector*)this->base)->insertSorted(newElement, comparator); } + { return ((untyped::Vector*)this->base)->insertSorted(newElement, + comparator); } inline void remove(int pos) { ((untyped::Vector*)this->base)->remove(pos); } inline T *get(int pos) const { return (T*)((untyped::Vector*)this->base)->get(pos); } - inline int size() const { return ((untyped::Vector*)this->base)->size(); } inline void clear() { ((untyped::Vector*)this->base)->clear(); } inline void sort(object::Comparator *comparator = &object::standardComparator) @@ -451,6 +469,8 @@ public: inline void clear() { ((untyped::List*)this->base)->clear(); } inline void append(T *element) { ((untyped::List*)this->base)->append(element); } + inline bool insertBefore(object::Object *beforeThis, object::Object *neew) + { return ((untyped::List*)this->base)->insertBefore(beforeThis, neew); } inline bool removeRef(T *element) { return ((untyped::List*)this->base)->removeRef(element); } inline bool remove(T *element) { @@ -458,7 +478,6 @@ public: inline bool detachRef(T *element) { return ((untyped::List*)this->base)->detachRef(element); } - inline int size() const { return ((untyped::List*)this->base)->size(); } inline bool isEmpty() const { return ((untyped::List*)this->base)->isEmpty(); } inline T *getFirst() const @@ -521,7 +540,6 @@ public: inline T *getTop () const { return (T*)((untyped::Stack*)this->base)->getTop (); } inline void pop () { ((untyped::Stack*)this->base)->pop (); } - inline int size() const { return ((untyped::Stack*)this->base)->size(); } }; } // namespace untyped diff --git a/lout/unicode.cc b/lout/unicode.cc index 4f0f0b3b..9fc2f3d3 100644 --- a/lout/unicode.cc +++ b/lout/unicode.cc @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2012, 2013 Sebastian Geerken <sgeerken@dillo.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + #include "unicode.hh" #include "misc.hh" @@ -385,81 +385,80 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) int safe = 0, ret = 0, use_cache = 0; /* web->requester is NULL if the action is initiated by user */ - if (!(a_Capi_get_flags(web->url) & CAPI_IsCached || - web->requester == NULL || - a_Domain_permit(web->requester, web->url))) { - return 0; - } - - /* reload test */ - reload = (!(a_Capi_get_flags(web->url) & CAPI_IsCached) || - (URL_FLAGS(web->url) & URL_E2EQuery)); - - if (web->flags & WEB_Download) { - /* download request: if cached save from cache, else - * for http, ftp or https, use the downloads dpi */ - if (a_Capi_get_flags_with_redirection(web->url) & CAPI_IsCached) { - if (web->filename) { - if ((web->stream = fopen(web->filename, "w"))) { - use_cache = 1; - } else { - MSG_WARN("Cannot open \"%s\" for writing.\n", web->filename); + if (a_Capi_get_flags(web->url) & CAPI_IsCached || + web->requester == NULL || + a_Domain_permit(web->requester, web->url)) { + + /* reload test */ + reload = (!(a_Capi_get_flags(web->url) & CAPI_IsCached) || + (URL_FLAGS(web->url) & URL_E2EQuery)); + + if (web->flags & WEB_Download) { + /* download request: if cached save from cache, else + * for http, ftp or https, use the downloads dpi */ + if (a_Capi_get_flags_with_redirection(web->url) & CAPI_IsCached) { + if (web->filename) { + if ((web->stream = fopen(web->filename, "w"))) { + use_cache = 1; + } else { + MSG_WARN("Cannot open \"%s\" for writing.\n", web->filename); + } } + } else if (a_Cache_download_enabled(web->url)) { + server = "downloads"; + cmd = Capi_dpi_build_cmd(web, server); + a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); + dFree(cmd); + } else { + MSG_WARN("Ignoring download request for '%s': " + "not in cache and not downloadable.\n", + URL_STR(web->url)); } - } else if (a_Cache_download_enabled(web->url)) { - server = "downloads"; - cmd = Capi_dpi_build_cmd(web, server); - a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); - dFree(cmd); - } else { - MSG_WARN("Ignoring download request for '%s': " - "not in cache and not downloadable.\n", - URL_STR(web->url)); - } - - } else if (Capi_url_uses_dpi(web->url, &server)) { - /* dpi request */ - if ((safe = a_Capi_dpi_verify_request(web->bw, web->url))) { - if (dStrAsciiCasecmp(scheme, "dpi") == 0) { - if (strcmp(server, "vsource") == 0) { - /* allow "view source" reload upon user request */ - } else { - /* make the other "dpi:/" prefixed urls always reload. */ - a_Url_set_flags(web->url, URL_FLAGS(web->url) | URL_E2EQuery); - reload = 1; + + } else if (Capi_url_uses_dpi(web->url, &server)) { + /* dpi request */ + if ((safe = a_Capi_dpi_verify_request(web->bw, web->url))) { + if (dStrAsciiCasecmp(scheme, "dpi") == 0) { + if (strcmp(server, "vsource") == 0) { + /* allow "view source" reload upon user request */ + } else { + /* make the other "dpi:/" prefixed urls always reload. */ + a_Url_set_flags(web->url, URL_FLAGS(web->url) |URL_E2EQuery); + reload = 1; + } + } + if (reload) { + a_Capi_conn_abort_by_url(web->url); + /* Send dpip command */ + _MSG("a_Capi_open_url, reload url='%s'\n", URL_STR(web->url)); + cmd = Capi_dpi_build_cmd(web, server); + a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); + dFree(cmd); + if (strcmp(server, "vsource") == 0) { + Capi_dpi_send_source(web->bw, web->url); + } } + use_cache = 1; } + dFree(server); + + } else if (!dStrAsciiCasecmp(scheme, "http")) { + /* http request */ if (reload) { a_Capi_conn_abort_by_url(web->url); - /* Send dpip command */ - _MSG("a_Capi_open_url, reload url='%s'\n", URL_STR(web->url)); - cmd = Capi_dpi_build_cmd(web, server); - a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); - dFree(cmd); - if (strcmp(server, "vsource") == 0) { - Capi_dpi_send_source(web->bw, web->url); - } + /* create a new connection and start the CCC operations */ + conn = Capi_conn_new(web->url, web->bw, "http", "none"); + /* start the reception branch before the query one because the DNS + * may callback immediately. This may avoid a race condition. */ + a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, "http"); + a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, web); } use_cache = 1; - } - dFree(server); - - } else if (!dStrAsciiCasecmp(scheme, "http")) { - /* http request */ - if (reload) { - a_Capi_conn_abort_by_url(web->url); - /* create a new connection and start the CCC operations */ - conn = Capi_conn_new(web->url, web->bw, "http", "none"); - /* start the reception branch before the query one because the DNS - * may callback immediately. This may avoid a race condition. */ - a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, "http"); - a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, web); - } - use_cache = 1; - } else if (!dStrAsciiCasecmp(scheme, "about")) { - /* internal request */ - use_cache = 1; + } else if (!dStrAsciiCasecmp(scheme, "about")) { + /* internal request */ + use_cache = 1; + } } if (use_cache) { diff --git a/src/cookies.h b/src/cookies.h index 1cdb82ac..5e4d8c59 100644 --- a/src/cookies.h +++ b/src/cookies.h @@ -5,18 +5,17 @@ extern "C" { #endif /* __cplusplus */ +void a_Cookies_init( void ); #ifdef DISABLE_COOKIES # define a_Cookies_get_query(url, requester) dStrdup("") # define a_Cookies_set() ; -# define a_Cookies_init() ; # define a_Cookies_freeall() ; #else char *a_Cookies_get_query(const DilloUrl *query_url, const DilloUrl *requester); void a_Cookies_set(Dlist *cookie_string, const DilloUrl *set_url, const char *server_date); - void a_Cookies_init( void ); void a_Cookies_freeall( void ); #endif diff --git a/src/html.cc b/src/html.cc index 89f9ec70..843b69ff 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2188,6 +2188,8 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, int tagsize) dw::Image *dw = new dw::Image(alt_ptr); image = a_Image_new(html->dw->getLayout(), (void*)(dw::core::ImgRenderer*)dw, 0); + + a_Image_ref(image); if (HT2TB(html)->getBgColor()) image->bg_color = HT2TB(html)->getBgColor()->getColor(); @@ -2204,10 +2206,10 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, int tagsize) if (load_now && Html_load_image(html->bw, url, html->page_url, image)) { // hi->image is NULL if dillo tries to load the image immediately hi->image = NULL; + a_Image_unref(image); } else { // otherwise a reference is kept in html->images hi->image = image; - a_Image_ref(image); } dFree(alt_ptr); @@ -688,20 +688,17 @@ static uint_t Url_host_public_internal_dots(const char *host) if (tld_len > 0) { /* These TLDs were chosen by examining the current publicsuffix list - * in February 2014 and picking out those where it was simplest for + * in October 2014 and picking out those where it was simplest for * them to describe the situation by beginning with a "*.[tld]" rule * or every rule was "[something].[tld]". * * TODO: Consider the old publicsuffix code again. This TLD list has * shrunk and shrunk over the years, and has become a poorer and - * poorer approximation of administrative boundaries -- and, as of - * mid-2014, even NZ and UK are allowing domains to be registered - * at the second level, which doesn't leave much. + * poorer approximation of administrative boundaries. */ - const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk", + const char *const tlds[] = {"bd","bn","ck","cy","er","fj","fk", "gu","il","jm","ke","kh","kw","mm","mz", - "ni","np","nz","pg","tr","uk","ye","za", - "zm","zw"}; + "ni","np","pg","ye","za","zm","zw"}; uint_t i, tld_num = sizeof(tlds) / sizeof(tlds[0]); for (i = 0; i < tld_num; i++) { diff --git a/test/cookies.c b/test/cookies.c index 40661650..ff744c97 100644 --- a/test/cookies.c +++ b/test/cookies.c @@ -880,17 +880,17 @@ int main() path(); /* LEADING/TRAILING DOTS AND A LITTLE PUBLIC SUFFIX */ - a_Cookies_set("name=val; domain=co.uk", "www.co.uk", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk", "/"); + a_Cookies_set("name=val; domain=co.il", "www.co.il", "/", NULL); + expect(__LINE__, "", "http", "www.co.il", "/"); - a_Cookies_set("name=val; domain=.co.uk", "www.co.uk", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk", "/"); + a_Cookies_set("name=val; domain=.co.il", "www.co.il", "/", NULL); + expect(__LINE__, "", "http", "www.co.il", "/"); - a_Cookies_set("name=val; domain=co.uk.", "www.co.uk.", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk.", "/"); + a_Cookies_set("name=val; domain=co.il.", "www.co.il.", "/", NULL); + expect(__LINE__, "", "http", "www.co.il.", "/"); - a_Cookies_set("name=val; domain=.co.uk.", "www.co.uk.", "/", NULL); - expect(__LINE__, "", "http", ".www.co.uk.", "/"); + a_Cookies_set("name=val; domain=.co.il.", "www.co.il.", "/", NULL); + expect(__LINE__, "", "http", ".www.co.il.", "/"); a_Cookies_set("name=val; domain=co.org", "www.co.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "www.co.org", "/"); |