I have a query in a php string which i am trying to filter against % signs.
The whole thing is in utf-8.
If the string contains % (for example %acheron) it gets converted to its equivalent entity (in the case I mention it becomes the ‘not’ sign character which is interpreted by the %ac sequence in the string).
I cant seem to be able to clean the incoming string of this character/
I cant clean the string with a php replace because by the time its in the script it is already “decoded?”.
The only way I found that I could figure out was to use rawurlencode and then clean it but it seems like a crappy solution and one that creates problems with other characters for me.
Is there some more efficient way to clearing these characters without affecting the rest of the string ? for instance I am looking for a function that would strip % & # (and any other) from the string, but leave it intact otherwise. (preg_replace is not working for me)
In other words is there a way to accept the string and clean it without any potentially special characters getting converted so that I can strip them from the string.
EDIT: The query is coming in via GET, wasn’t clear on that.
EDIT2: With urlecode or rawurl encode :
%acheron is converted to %ACheron (which could be cleaned I guess) but
^acheron is converted to %5Eacheron (thus making it almost impossible to clean it via a pattern)…
Please excuse the noobishness of my question
Thanks
Larry
Something like this? This should work, if I understood your problem.
EDIT: Ok this is what you’re looking for: