小编Bri*_*hon的帖子

HTML Agility Pack strip标签不在白名单中

我正在尝试创建一个删除不在白名单中的html标签和属性的函数.我有以下HTML:

<b>first text </b>
<b>second text here
       <a>some text here</a>
 <a>some text here</a>

 </b>
<a>some twxt here</a>
Run Code Online (Sandbox Code Playgroud)

我正在使用HTML敏捷包,到目前为止我的代码是:

static List<string> WhiteNodeList = new List<string> { "b" };
static List<string> WhiteAttrList = new List<string> { };
static HtmlNode htmlNode;
public static void RemoveNotInWhiteList(out string _output, HtmlNode pNode, List<string> pWhiteList, List<string> attrWhiteList)
{

 // remove all attributes not on white list
 foreach (var item in pNode.ChildNodes)
 {
  item.Attributes.Where(u => attrWhiteList.Contains(u.Name) == false).ToList().ForEach(u => RemoveAttribute(u));

 }

 // remove all html and their innerText …
Run Code Online (Sandbox Code Playgroud)

c# tags sanitize html-parsing html-agility-pack

30
推荐指数
2
解决办法
2万
查看次数

SDDL格式的SID的最大长度是多少

我正在将Active Directory身份验证构建到我的应用程序中,并且我计划将应用程序的内部帐户链接到用户的域SID.我更容易使用sid的字符串格式而不是字节数组,所以我打算将它作为字符串存储在数据库中.我应该多长时间来确保SID不会被截断?

authentication sid active-directory

18
推荐指数
1
解决办法
2万
查看次数

Jquery UI自动完成组合框按钮单击事件

使用jquery ui自动完成功能创建组合框时,我遇到了奇怪的行为.每当我单击滚动条滚动查看结果列表然后单击我的组合框按钮以关闭结果列表关闭结果然后再次打开.我希望它关闭菜单.

Repro的步骤

  1. 打开jsfiddle演示
  2. 在自动完成中键入"i"或按下下拉按钮.
  3. 单击垂直滚动以滚动结果
  4. 单击下拉按钮

用于创建按钮的脚本

 this.button = $("<button type='button'>&nbsp;</button>")
    .attr({ "tabIndex": -1, "title": "Show all items" })
    .insertAfter(input)
    .button({
         icons: {
             primary: "ui-icon-triangle-1-s"
         },
         text: false
    })
    .removeClass("ui-corner-all")
    .addClass("ui-corner-right ui-button-icon")
    .click(function () {

        // when i put breakpoint here, and my focus is not on input, 
        // then this if steatment is false????

        if (input.autocomplete("widget").is(":visible")) {
            input.autocomplete("close");
            return;
        }

        // work around a bug (likely same cause as #5265)
        $(this).blur();

        // pass empty string as …
Run Code Online (Sandbox Code Playgroud)

javascript jquery combobox jquery-ui jquery-autocomplete

15
推荐指数
1
解决办法
1万
查看次数

一对多投影的LINQ查询重复执行

我正在将LINQ to SQL结果投射到强类型类:Parent和Child.这两个查询之间的性能差异很大:

慢查询 - 从DataContext记录显示正在为每个父级单独调用db

var q = from p in parenttable
        select new Parent()
        {
            id = p.id,
            Children = (from c in childtable
                        where c.parentid = p.id
                        select c).ToList()
        }
return q.ToList()  //SLOW
Run Code Online (Sandbox Code Playgroud)

快速查询 - 从DataContext进行日志记录显示单个数据库命中查询,该查询返回所有必需数据

var q = from p in parenttable
        select new Parent()
        {
            id = p.id,
            Children = from c in childtable
                        where c.parentid = p.id
                        select c
        }
return q.ToList()  //FAST
Run Code Online (Sandbox Code Playgroud)

我想强制LINQ使用第二个示例的单一查询样式,但直接用Parent对象填充Parent类.否则,IQuerierable<Child>必须查询Children属性以公开Child对象.

引用的问题似乎并不能解决我的情况.使用db.LoadOptions不起作用.也许它要求类型是在DataContext中注册的TEntity.

   DataLoadOptions options = new DataLoadOptions();
   options.LoadWith<Parent>(p => …
Run Code Online (Sandbox Code Playgroud)

c# performance linq-to-sql

6
推荐指数
2
解决办法
3446
查看次数