本文整理汇总了C++中WApplication::encodeUntrustedUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ WApplication::encodeUntrustedUrl方法的具体用法?C++ WApplication::encodeUntrustedUrl怎么用?C++ WApplication::encodeUntrustedUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WApplication
的用法示例。
在下文中一共展示了WApplication::encodeUntrustedUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDom
void WImage::updateDom(DomElement& element, bool all)
{
DomElement *img = &element;
if (all && element.type() == DomElement_SPAN) {
DomElement *map = map_->createSDomElement(WApplication::instance());
element.addChild(map);
img = DomElement::createNew(DomElement_IMG);
img->setId("i" + id());
}
if (flags_.test(BIT_IMAGE_LINK_CHANGED) || all) {
if (!imageLink_.isNull()) {
std::string url = resolveRelativeUrl(imageLink_.url());
WApplication *app = WApplication::instance();
url = app->encodeUntrustedUrl(url);
img->setProperty(Wt::PropertySrc, url);
} else
img->setProperty(Wt::PropertySrc, "#");
flags_.reset(BIT_IMAGE_LINK_CHANGED);
}
if (flags_.test(BIT_ALT_TEXT_CHANGED) || all) {
img->setAttribute("alt", altText_.toUTF8());
flags_.reset(BIT_ALT_TEXT_CHANGED);
}
if (flags_.test(BIT_MAP_CREATED) || (all && map_)) {
img->setAttribute("usemap", '#' + map_->id());
flags_.reset(BIT_MAP_CREATED);
}
WInteractWidget::updateDom(*img, all);
if (&element != img)
element.addChild(img);
}
示例2: updateDom
void WAnchor::updateDom(DomElement& element, bool all)
{
if (element.type() != DomElement_A) {
WContainerWidget::updateDom(element, all);
return;
}
if (flags_.test(BIT_CHANGE_TAG)) {
if (!all)
element.callJavaScript(WT_CLASS ".changeTag(" + jsRef() + ",'a');");
flags_.reset(BIT_CHANGE_TAG);
}
bool needsUrlResolution = false;
if (flags_.test(BIT_LINK_CHANGED) || all) {
WApplication *app = WApplication::instance();
std::string url = link_.resolveUrl(app);
/*
* From 但浩亮: setRefInternalPath() and setTarget(TargetNewWindow)
* does not work without the check below:
*/
if (target_ == TargetSelf)
changeInternalPathJS_
= link_.manageInternalPathChange(app, this, changeInternalPathJS_);
else {
delete changeInternalPathJS_;
changeInternalPathJS_ = 0;
}
url = app->encodeUntrustedUrl(url);
std::string href = resolveRelativeUrl(url);
element.setAttribute("href", href);
needsUrlResolution = !app->environment().hashInternalPaths()
&& href.find("://") == std::string::npos && href[0] != '/';
flags_.reset(BIT_LINK_CHANGED);
}
if (flags_.test(BIT_TARGET_CHANGED) || all) {
switch (target_) {
case TargetSelf:
if (!all)
element.setProperty(PropertyTarget, "_self");
break;
case TargetThisWindow:
element.setProperty(PropertyTarget, "_top");
break;
case TargetNewWindow:
element.setProperty(PropertyTarget, "_blank");
}
flags_.reset(BIT_TARGET_CHANGED);
}
WContainerWidget::updateDom(element, all);
if (needsUrlResolution) {
if (all)
element.setProperty(PropertyClass,
Utils::addWord(styleClass().toUTF8(), "Wt-rr"));
else
element.callJavaScript("$('#" + id() + "').addClass('Wt-rr');");
}
}