Umbraco Lucene search breaking on 'special characters' - lucene

When a user inputs certain special characters i.e a html tag, the user receives this:
Error loading Partial View script (file: ~/Views/MacroPartials/ezSearch.cshtml)
I have been investigating and this seems to be a common issue and I attempted to apply a fix so it would strip out 'bad' characters:
public string CleanseSearchTerm(string input)
{
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");
input = rgx.Replace(input, "");
return input.ToString();
}
However, the issue is that this error is getting generated before it has a chance to hit my method to strip out 'bad' characters. Any ideas of how this can be resolved?

I haven't tried these changes myself Kyle but I have done some investigation to help you fix this problem. Could one of the following solutions help you?
See this Umbraco form question and its answers, especially the one from Ismail Mayat could help you.
Linked to Ismail's answer, there is also this "How to make the Lucene QueryParser more forgiving?" question and I'd recommend you to check the answers for this question, too.
Another answer that might help you is this stackoverflow answer.

Lucene.NET does contain a few classes to help with HTML stripping. These classes are located here in the Lucene.NET repo. Specifically, the HTMLStripCharFilter may be of interest.

Related

How do I select only visible elements using selectors

Hi guys I have the issue as a question that was answered called:
How do I select only visible elements using XPath?
The response was: //div[not(contains(#style,'display:none'))]//button[.='OK'].
My question is how do I adapt the above for aria-hidden='true', I'm trying to find elements that are only aria-hidden='false'?
I do apologize if my approach is messy, I'm kinda new to asking questions on here
Thanks
You can try adding another search criteria, depending on if the aria-hidden='false' applies to the div
//div[not(contains(#style,'display:none')) and #aria-hidden='true')]//button[.='OK']
or the button
//div[not(contains(#style,'display:none'))]//button[.='OK' and #aria-hidden='true']
There are some more examples here.
If I understand well, you could adapt with your example this way:
driver.find_element_by_xpath("//div[#aria-hidden='false']//button[.="OK"]")
Don't hesitate to share an URL or HTML code if my answer is not correct.
Finally with more than an hour of searching, trial and error, I found what I was looking for ^-^.. the pain
//a[contains(#aria-hidden, 'false') and contains(.,'text')]

Comments that control uncrustify behaviour

In this question (https://stackoverflow.com/questions/15097501/can-uncrustify-be-prevented-from-modifying-certain-sections-of-code) i learned that i can use *INDENT-OFF* to exclude uncrustify action on certain parts of code.
Unfortunately i was not able to find this information anywhere else.
Does anybody know where i can look this up? Are there other comments which control uncrustifiy behaviour?
The *INDENT-ON* and *INDENT-OFF* are defined in the uncrustify_types.h file in the source code
See also Ben Gardner's comment: https://sourceforge.net/p/uncrustify/bugs/343/#0394

custom error pages for IBM Domino iNotes

we're currently customizing iNotes for a customer (platform currently is Domino 9). We almost reached our goals, but one thing that's on our todo list I can't really figure out: they want us to also customize any possible error pages; see the following example screenshot:
This and other similar pages seem to come from the central Forms9.nsf which I'd love to leave as it is. We so far tried domcfg.nsf mappings, but as this is an iNotes internal error it obviously can't work; I also tried to figure out a way to put seomething into our customized Forms9_x.nsf but without any hint this is too abstract for me.
So my questions are:
has anyone ever done this?
what options do we have (apart from "hacking" Forms9.nsf)?
Many thanks in advance...
Update:
After continuing to play with domcfg mappings I suddenly saw a first result; not sure what's the difference to the first attempts, though; maybe moving the error form to Forms9_x.nsf did the trick? I'll keep investigating and post an answer if I can find one...
Alright, this has been an afternoon of wild guessing and hacking along, but finally I think I found it:
first of all, my playing around with domcfg mappings didn't have to do with solving the problem; instead, I just by chance had put my error page form into my Forms9_x.nsf and named it $$ReturnGeneralError (that's simply the name used in Forms9.nsf...; I completely had forgotton about those 4 pre-defined form names back from Domino 5 times).
What did not work was the old method of simply including a text file named MessageString to display the exact error message returned from the server; obviously iNotes is handling those error strings differently.
After a few hours of testing, and comparing codes between the standard iNotes error page and mine I finally found it: include some iNotes specific computed text into the page, in my case that is
#{{MessageString}; html}
See this document for some details (last row in the table)
Hopefully this can help someone else as well...

Replace All Instances of HTML Comments in Database

I recently imported quite a few posts (many thousands) into WordPress and found out that quite a few of them had images at the start of the post that were commented out
<!--<img src="" />-->.
Unfortunately WordPress for whatever reason is adding this comment to all the content, so the content is there but doesn't show up. So I figured the easy way to solve this was to run a find and replace SQL statement, to find all instances and replace with nothing.
I haven't been able to figure out how to get it to work. I'm no expert with SQL, so I was figuring I could use a wildcard in the find statement but apparently not, or at least I can't figure it out.
So what I want to do is find all occurrences of commented out images and replace them with nothing, basically just delete them. The images aren't all the same. Some just have a src, some also have height and width, some have alt attributes, etc. And they are not all in the same order. So I was hoping something like UPDATE wp_posts set post_content = replace(post_content, '<!--<img %>-->', '') would work, but it doesn't.
So if anyone has any ideas on how to do this, I'd be grateful for the help.
Have you had a look at this question. I think your problem is using the '%' without a LIKE does not work. The question recommends using a user defined function

Rails 3 Post/Comments with Formatting (like in stackoverflow)

I was wondering, it would be great to know how to allow users to format their posts in Ruby on Rails 3. Ideally, i was wondering if there are any gems or solutions to implementing a formatting system similar to stackoverflow, where the user can bold and underline text, and so on (ie provides a little partial above the post input field similar to the one above the input field we use to ask questions).
Any ideas?
Thanks everyone!
If anyone is still interested in this question, there are a bunch of options for formatting comments and for text editor helpers.
To be brief, I've checked out a whole bunch of options - but I found one that I think is awesome: ckeditor. Check it out at https://github.com/galetahub/ckeditor