Project

General

Profile

Error with WText links?

Added by Andres Jaimes about 12 years ago

Hello,

I have created a list of links using a WContainerWidget (as ul) and WText's (as li's). The code I use to generate them is the following:

content->addWidget(new WText("<h2>Previous Events</h2>"));
ul = new WContainerWidget(content);
ul->setList(true, false);
result = GlobalDao::selectInactiveEvents();
for (std::vector<AppModel::EventListItem>::const_iterator it = result->begin(); it != result->end(); it++) {
    WContainerWidget* li = new WContainerWidget(ul);
    li->addWidget(new WText("<a href=\"?id=" + it->get<0>() + "\">" + it->get<1>() + "</a>"));
}

However, from time to time the "" text is replaced by "<a>" breaking some links. It does not seem to have a pattern, but I'm attaching an image so you can see what is happening...

Would you please help me?

Thanks...

anchor.gif (8.4 KB) anchor.gif Links are not always showing the way they should

Replies (2)

RE: Error with WText links? - Added by Andres Jaimes about 12 years ago

Changing WText to use Wt::XHTMLUnsafeText fixed the problem. I'll take a look at the source code to see why this is happening...

Thanks...

RE: Error with WText links? - Added by Koen Deforche about 12 years ago

Hey,

S&S is not valid HTML (it needs to be S&S. Wt converts this to plain text when it fails to validate (and XSS parse) the fragment.

So you need to Utils::htmlEncode() the it->get<1>() value. Why are you not using a WAnchor instead however ?

Regards,

koen

    (1-2/2)