Find terms featuring ampersands like H&M

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Find terms featuring ampersands like H&M

This topic contains 4 replies, has 2 voices, and was last updated by Paul Brown Paul David Brown 7 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11235
    Paul Brown
    Paul David Brown
    Participant

    Hi There,

    I hope you are having a good week, I am really enjoying setting up the Ajax Search Pro Plugin.. I have hit a small glitch though. From what I can see you do not offer any way to provide manual synonyms within setup. Unfortunatly WP sanitises “&” turning them to “%amp.;”. Then your plugin is unable to find those terms.

    Do you have a work around for terms like H&M? I would rather not reduce sanitisation within core WP functions.

    Any help you can give would be appreciated, some of the other search plugins seem to have found away around this. Hopefully we can here too as everything else is spot on.

    Thanks

    Paul

    #11241
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Paul,

    I’ve actually had to look up how this was changed and used previously. The problem with sanitation in wordpress is that some fields are sanitised, some fields are not (as stored in the database). This creates a huge issue, as the plugin would have to preferably use the same type of sanitation methods before comparison on these specific fields. It’s however still not clear to me how the exact sanitation process runs down on the post content and how to properly convert the search phrase back to it, and minding potential dangers of SQL injections and such.

    In the meantime the Index Table engine was developed, which circumvents this problem completely. Many search engines use a similar technique. So instead converting the search phrase through a number of sanitation processes and then escaping and testing, the index table was created to separate the content to words, and store them as they are – since they are not re-presented in any way.

    Long story short: I could recommend modifications to sanitize the search phrase on specific occasions in the code, but I’m not sure what vulnerabilities would that cause (if any). Instead, I recommend using the index table engine – which allows mos of the “special” characters to be stored and searched untouched.

    I’ve noted this as an issue, and will look into it before the upcoming version releases. I might find a proper, transparent solution for the default “regular” engine as well.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #11246
    Paul Brown
    Paul David Brown
    Participant

    Hi Ernest,

    Thank you very much for the comprehensive reply…

    So do you mean the Index Table Engine should work for me in the current version? I have played around with it since before I spoke to you an the best I get is that “H & M” works. This is not good enough though as H&M is the more commonly typed method.

    Just to be clear H&M in this case is a custom taxonomy – the main reason I bought your plugin was its ability to search taxonomies

    Having done some extra tests now… I have created a post called H&M sale now on and looked in the database and the sanitisation is not at play there. it is saved as straight up “H&M”. Sorry I should have checked this before I posted originally.

    Maybe one way to get this to work for taxonomies – which is important for me – is the ability to create synonyms for certain taxonomy terms. This could be done within your plugin or via something like Advanced Custom Fields. The issue with using ACF, is that your plugin is not currently supporting the new wp_termmeta table by the look of it. As fields created in this table are not found by your plugin. If you could index this table, the synonyms are saving correctly (for example) as H&M not H&amp.;M.

    Would be great if you can give me some pointers on this. I would like to discuss the idea of getting the images created in termmeta to show too after this more pressing issue is resolved.

    Many thanks for you help on this.

    Paul.B

    #11252
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Paul,

    Oh, I thought we are talking about custom post type contents, in this case the index table won’t help, as the taxonomy term tables don’t need indexing.

    I actually thought that taxonomy terms are stored with sanitation, it doesn’t make sense, but I guess today I learned something new. I might have come up with a possible solution, without touching the plugin code. Try putting this into the functions.php file in your active theme directory:

    This will try to detect differences in sanitised / unsanitised inputs and appends a new search phrase if finds anything.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #11254
    Paul Brown
    Paul David Brown
    Participant

    You beauty! That worked like a charm Ernest 🙂

    Thank you so much for pulling that together, it could be worth adding the link to that github snippet in the troubleshooting section of your docs.

    – I am heading straight over to rate the product & services 5 stars.

    🙂

    Regarding passing other information through from taxonomies (custom field data like image), is it ok if I start another ticket for that? It is not urgent but feel it could be a nice to have feature.

    Thanks

    Paul

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Find terms featuring ampersands like H&M’ is closed to new replies.