It is currently Sun Dec 16, 2018 5:19 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Display invisible chars in IDE
PostPosted: Wed Oct 31, 2018 4:03 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4051
Location: Germany
Hi,

If I use a header map with Content-Type and other 'normal' headers it works a it should.
But this:
Code:
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:
Quote:
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.

Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.70b2 HTTPMemory() Header Map
PostPosted: Sat Nov 03, 2018 10:20 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jun 08, 2004 10:29 am
Posts: 181
Location: Zurich, Switzerland
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.70b2 HTTPMemory() Header Map
PostPosted: Sun Nov 04, 2018 10:29 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4051
Location: Germany
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:
*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:
Token$ = "X-Auth-Token: " + #X_Auth_Token$
*headers = curl_slist_append(*headers, Token$)

It fails in the same way.

Only working version:
Code:
*headers = curl_slist_append(*headers, "X-Auth-Token: 123456"


I use
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.70b2 HTTPMemory() Header Map
PostPosted: Mon Nov 19, 2018 2:16 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13436
Location: France
I will take a look


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.70b2 HTTPMemory() Header Map
PostPosted: Mon Nov 19, 2018 10:16 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13436
Location: France
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:
_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.


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.70b2 HTTPMemory() Header Map
PostPosted: Tue Nov 20, 2018 8:34 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4051
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved]PB 5.70b2 HTTPMemory() Header Map
PostPosted: Tue Nov 20, 2018 8:44 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4051
Location: Germany
Unfortunately there are not 24 invisible characters available :wink:

https://en.wikipedia.org/wiki/Zero-width_space
https://en.wikipedia.org/wiki/Whitespace_character

For german readers:
https://de.wikipedia.org/wiki/Breitenloses_Leerzeichen


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved]PB 5.70b2 HTTPMemory() Header Map
PostPosted: Tue Nov 20, 2018 9:21 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13436
Location: France
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye