Display invisible chars in IDE

Working on new editor enhancements?
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Display invisible chars in IDE

Post by infratec »

Hi,

If I use a header map with Content-Type and other 'normal' headers it works a it should.
But this:

Code: Select all

InitNetwork()

NewMap Header$()
Header$("Content-Type") = "application/json"
Header$("x-auth-token") = "​​123"

HTTPRequest(#PB_HTTP_Post, "http://www.purebasic.fr", "Test", 0, Header$())
Results in:
x-auth-token: \342\200\213\342\200\213123\r\n
Content-Type: application/json\r\n

0090 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 78 2d 61 Accept: */*..x-a
00a0 75 74 68 2d 74 6f 6b 65 6e 3a 20 e2 80 8b e2 80 uth-token: â..â.
00b0 8b 31 32 33 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 .123..Content-Ty
00c0 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f pe: application/
00d0 6a 73 6f 6e 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 json..Content-Le
Independent of the string it puts $e2808b $e2808b in front of the string.

Very strange, since other custom headers works as expected.

Bernd
Last edited by infratec on Tue Nov 20, 2018 8:34 am, edited 1 time in total.
wayne-c
Enthusiast
Enthusiast
Posts: 335
Joined: Tue Jun 08, 2004 10:29 am
Location: Zurich, Switzerland

Re: PB 5.70b2 HTTPMemory() Header Map

Post by wayne-c »

I encountered a probably similar bug when sending a custom "Authorization" header with Base64-encoded Username:Password; as soon as there are accents (e.g. "é") inside the Password, the authorization is rejected by the service. I did not check with Wireshark what is actually transferred but I assume now that this could be the same error than yours and the Header is not transferred correctly!
As you walk on by, Will you call my name? Or will you walk away?
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PB 5.70b2 HTTPMemory() Header Map

Post by infratec »

I did further investigations:

I changed the code and used libcurl directly.
With very strange results.

First I declared a constant for the authcode, since it is fixed in my application.

Code: Select all

*headers = curl_slist_append(*headers, "X-Auth-Token: " + #X_Auth_Token$)
It fails in the same way.

The I thought: may be the string buffer is not avalaible when it is needed
and I used an extra variable.

Code: Select all

Token$ = "X-Auth-Token: " + #X_Auth_Token$
*headers = curl_slist_append(*headers, Token$)
It fails in the same way.

Only working version:

Code: Select all

*headers = curl_slist_append(*headers, "X-Auth-Token: 123456"
I use

Code: Select all

curl_slist_append(slist.i, string.p-utf8)
for the import.

So 2 possibilities:
1. Something with p-utf8 is not 100% Ok
2. A bug in libcurls curl_slist_append()

I searched in the web for 2. but I found no informations about a bug.
Also a curl.exe request works as expected (Ok, there is also the complete string at once provided)

I have no chance to go deeper inside.

Bernd
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 5.70b2 HTTPMemory() Header Map

Post by Fred »

I will take a look
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 5.70b2 HTTPMemory() Header Map

Post by Fred »

I spend some time on this one, but it's not a PB bug: your string contains some hidden characters and PB create it like this in datasection for "123":

Code: Select all

_S4: dw 8203,8203,49,50,51,0
As you can see, there is 2 extra character in the literal string. Just delete the string completely from the IDE and retype it and it will be gone.
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PB 5.70b2 HTTPMemory() Header Map

Post by infratec »

Hi Fred,

thank you for your time.
Originally I copied the string from an e-mail.

Then it was not working and I deleted it from the end via backspace and added 123.
Unfortunately the 2 hidden characters stayed.

But how should I know something about these characters? They are invisible.
Very strange.

I'll check if there are 24 different invisible characters available, then I'll write a procedure which allows to send 'invisible' text via e-mails :mrgreen:

Bernd
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [Solved]PB 5.70b2 HTTPMemory() Header Map

Post by infratec »

Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Solved]PB 5.70b2 HTTPMemory() Header Map

Post by Fred »

May be the IDE should display these, dunno if we can force scintilla to do so.

Edit: #SCI_SETREPRESENTATION seems the way to go, I will add some characters mapping in the IDE so it will be displayed
Post Reply