4

I have the following string sent to the server by a client:

3%D3%E1f%7C%AF%B0a%B58%81%92%F9M%90%0CD%A0Y%9C // string in the actual URL
3Óáf|¯°aµ8’ùMD Yœ // var_dump($_GET)

The original string should be:

33D3E1667CAFB061B5388192F94D900C44A0599C

My problem is that I can't figure out how to encode/decode this so I can peform a database search because the collation type does not match. I have tried to urlencode/urldecode, mb_string_convert, utf8_encode, iconv, but without luck. Any ideas ?

Laravel throws the following exception when trying to use the string for searching:

'SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)...

I have no control of what the client's encoding is. The strange value is from logging it to a log file using Laravel's Log::imfo()

2
  • 1
    @SugumarVenkatesan: this is not an attack, it is me testing. he thing is I need that data in the original value. Commented Dec 31, 2015 at 13:49
  • @MichaelBerkowski: the client is a bittorrent client and the sent parameter is an info_hash one. The request is sent and received via GET, and I don't think that it can be changed. Commented Dec 31, 2015 at 14:01

2 Answers 2

2

Have you tried sending a post request instead of a get request, and send the string as the actual string.

Or maybe change your database encoding to UTF-8 (it handles swedish just fine, no need to choose latin-swedish version).

Sign up to request clarification or add additional context in comments.

1 Comment

Changing the database collation fixes part of the problem, namely the exception. The initial problem is solved by calling bin2hex(), as specified in my answer.
1

The solution is to retrieve the parameter with the bin2hex() function call.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.