flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > It is possible to have username http or https or mailto

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 354
Location: Russian Federation, Sochi
Is anybody know is there any URI format limitation for using as username literal identic name of one of protocols(for ex. http, https, mailto? (Post servers are smart and they dont let me do such things) But it maybe their own fix of standard?

if https:\\https@board.flatassembler.net would exist, so how would tractacted short form https:@board.flatassembler.net as protocol or as username?

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 21 Jul 2019, 14:15
View user's profile Send private message Send e-mail Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1429
Host names can only have alphanumeric characters and the dash (-). So with @ there would be no ambiguity.

Maybe you want to look at: https://en.wikipedia.org/wiki/Punycode. If you want to encode @ into a hostname, that is.
Post 22 Jul 2019, 11:45
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 354
Location: Russian Federation, Sochi
I tryed to write something as parser of URI in pseudo asm(or in asm directly)
Code:
':/@?=#'

;''=$0
;'#'=$23
;'.'=$2E
;'/'=$2F
;':'=$3A
;'='=$3D
;'?'=$3F
;'@'=$40

URI.Table:
db 0*'.',$2 or $4 or $20 or $40
db 0*'0',0*'1',0*'2',0*'3',0*'4',0*'5',0*'6',0*'7'
db 0*'8',0*'9',$1 or $8 or $10,0*';',0*'<',  $80,0*'>',  $80

URI.BookmarkStarter     = '#'
URI.ParamsStarter       = '?'
URI.ParamsAltStarter    = '='

struct URIstruct
  Pchar                 dd ?
  SchemeTokenPos        dd ? ; has no dots before
  DblSlashTokenPos      dd ? ; can be only on next char after SchemeToken
  UserCredentialsSepPos dd ?
  UserCredentialsEndPos dd ?
  PortStarterTokenPos   dd ?
  FirstPathDelimiterPos dd ?
  LastPathDelimiterPos  dd ?
  ParamsStarterTokenPos dd ?
  BookmarksTokenPos     dd ?
  Length                dd ?
ends


;parse URI modes:
P_URI_PROTOCOL_OR_PATH  = 0
P_URI_DBLSLASH_OR_PATH  = 1 ; this mode could be cuted off, incapsulated in colon parsing
P_URI_AUTORITY_OR_PATH  = 2
P_URI_PASSWORD_OR_PORT  = 3
P_URI_PASSWORD_OR_ERROR = 4
P_URI_HOST              = 5
P_URI_HOST_OR_ERROR     = 6
P_URI_PORT              = 7
P_URI_PATH_OR_DOCUMENT  = 8
P_URI_PATH_OR_ERROR     = 9
P_URI_PARAMS            = 10
P_URI_BOOKMARK          = 11

URI URIstruct
parseURImode db P_URI_PROTOCOL_OR_PATH

cleanURI:
        mov     edi, URI
        mov     ecx, 11
        xor     eax,eax
        cld
        rep stosd
        ret

parseURI.processSpace.Table:
        dd      .URImodeToPath,         \;P_URI_PROTOCOL_OR_PATH
                .URImodeToPath,         \;P_URI_DBLSLASH_OR_PATH
                .URImodeToPath,         \;P_URI_AUTORITY_OR_PATH
                .URImodeToPassOrError,  \;P_URI_PASSWORD_OR_PORT
                .loop,                  \;P_URI_PASSWORD_OR_ERROR
                .error,                 \;P_URI_HOST
                .error,                 \;P_URI_HOST_OR_ERROR
                .error,                 \;P_URI_PORT
                .URImodeToPathOrError,  \;P_URI_PATH_OR_DOCUMENT
                .loop,                  \;P_URI_PATH_OR_ERROR
                .loop,                  \;P_URI_PARAMS
                .loop                    ;P_URI_BOOKMARK

parseURI.processMinus.Table:
        dd      .URImodeToHostOrError,  \;P_URI_PROTOCOL_OR_PATH
                .URImodeToHostOrError,  \;P_URI_DBLSLASH_OR_PATH
                .URImodeToHostOrError,  \;P_URI_AUTORITY_OR_PATH
                .URImodeToPassOrError,  \;P_URI_PASSWORD_OR_PORT
                .loop,                  \;P_URI_PASSWORD_OR_ERROR
                .loop,                  \;P_URI_HOST
                .loop,                  \;P_URI_HOST_OR_ERROR
                .error,                 \;P_URI_PORT
                .loop,                  \;P_URI_PATH_OR_DOCUMENT
                .loop,                  \;P_URI_PATH_OR_ERROR
                .loop,                  \;P_URI_PARAMS
                .loop                    ;P_URI_BOOKMARK

parseURI.processDot.Table:
        dd      .URImodeToAuthority,    \;P_URI_PROTOCOL_OR_PATH
                .URImodeToAuthority,    \;P_URI_DBLSLASH_OR_PATH
                .loop,                  \;P_URI_AUTORITY_OR_PATH
                .URImodeToPassOrError,  \;P_URI_PASSWORD_OR_PORT
                .loop,                  \;P_URI_PASSWORD_OR_ERROR
                .loop,                  \;P_URI_HOST
                .loop,                  \;P_URI_HOST_OR_ERROR
                .error,                 \;P_URI_PORT
                .loop,                  \;P_URI_PATH_OR_DOCUMENT
                .loop,                  \;P_URI_PATH_OR_ERROR
                .loop,                  \;P_URI_PARAMS
                .loop                    ;P_URI_BOOKMARK

parseURI.processSlash.Table:
        dd      .URImodeToPath,         \;P_URI_PROTOCOL_OR_PATH
                .URImodeToPath,         \;P_URI_DBLSLASH_OR_PATH
                .URImodeToPath,         \;P_URI_AUTORITY_OR_PATH
                .URImodeToPath,         \;P_URI_PASSWORD_OR_PORT
                .error,                 \;P_URI_PASSWORD_OR_ERROR
                .URImodeToPath,         \;P_URI_HOST
                .URImodeToPath,         \;P_URI_HOST_OR_ERROR
                .URImodeToPath,         \;P_URI_PORT
                .URImodePathNewSlash,   \;P_URI_PATH_OR_DOCUMENT
                .URImodePathNewSlash,   \;P_URI_PATH_OR_ERROR
                .loop,                  \;P_URI_PARAMS
                .loop                    ;P_URI_BOOKMARK



parseURI:
; [esp] - ret
; [esp+4] - PChar
        push    ebx
        push    esi
        push    edi
        call    cleanURI
        mov     edi, URI
        mov     esi, [esp+4]
        mov     [edi+URIstruct.Pchar], esi
        mov     ebx, URI.Table-'.'

      .loop:
        lodsb
        test    al, al
        jnz     .test
        jmp     .finish

      .test:
        call    .cmpALPHA
        ja      .testHi
        call    .cmpSPACE
        call    .cmpSHARP
        sub     al, '-'
        jb      .unsafeSym
        jmp     [.testLoTable+eax*4]
      .testLoTable:
        dd      .processMinus,.processDot,.processSlash
      .testHi:
        sub     al, ':'
        jmp     [.testHiTable+eax*4]
      .testLoTable:
        dd      .processColon,.unsafeSym,.unsafeSym,.processQuery,.unsafeSym,.processQuery,.processCat

      .cmpSPACE:
        cmp     al, ' '
        je      .processSpace
        ja      .cmpSPACE.locret
        jmp     .error
      .processSpace:
        cmp     [parseURImode], P_URI_PASSWORD_OR_PORT
        jb      .ToPath
        ja      .ToPassErr
        mov     eax, [parseURImode]
        jmp     [.processSpace.Table+eax*4]
      .cmpSPACE.locret:
        ret

      .processColon:
        pop     eax
        mov     eax, [parseURImode]
        test    eax, eax
        jnz     .notSchemeEnder
        dec     esi
        mov     [edi+URIstruct.SchemeTokenPos], esi
        inc     esi
        cmp     word[esi], '//'
        jnz     .notSchemeEnder
        mov     [edi+URIstruct.DblSlashTokenPos], esi
        mov     [parseURImode], P_URI_AUTORITY_OR_PATH
        jmp     .loop
      .notSchemeEnder:
        cmp     eax, P_URI_AUTORITY_OR_PATH
        jne     .notUserPassSep
        dec     esi
        mov     [edi+URIstruct.UserCredentialsSepPos], esi
        inc     esi
        mov     [parseURImode],P_URI_PASSWORD_OR_PORT
        jmp     .loop
      .notUserPassSep:
        cmp     eax, P_URI_HOST
        je      .HostPortSep
        cmp     eax, P_URI_HOST_OR_ERROR
        jne     .notHostPortSep
        dec     esi
        mov     [edi+URIstruct.PortStarterTokenPos], esi
        inc     esi
        mov     [parseURImode],P_URI_PORT
        jmp     .loop
      .notHostPortSep:
        cmp     eax, P_URI_PATH_OR_ERROR
        ja      .ColonOK
        jmp     .error
      .ColonOK:
        jmp     .loop

      .processCat:
        pop     eax
        mov     eax, [parseURImode]
        cmp     eax, P_URI_HOST
        jb      .UserHostSep
        jmp     .notHostPortSep
      .UserHostSep:
        dec     esi
        mov     [edi+URIstruct.UserCredentialsEndPos], esi
        inc     esi
        mov     [parseURImode],P_URI_HOST_OR_ERROR
        jmp     .loop

      .processQuery:
        cmp     [parseURImode],P_URI_PASSWORD_OR_ERROR
        jne     .QueryNotPassError
        jmp     .error
      .QueryNotPassError:
        cmp     [parseURImode],P_URI_PARAMS
        jb      .QueryStarter
        jmp     .loop
      .QueryStarter:
        dec     esi
        mov     [edi+URIstruct.ParamsStarterTokenPos], esi
        inc     esi
        mov     [parseURImode],P_URI_PARAMS
        jmp     .loop

      .processMinus:
        cmp     [parseURImode],P_URI_PORT
        jne     .PrePort
        jmp     .error
      .PrePort:
        cmp     [parseURImode],P_URI_PASSWORD_OR_PORT
        je      .EnsurePass
        jb      .HostStarter
        jmp     .loop
      .EnsurePass:
        mov     [parseURImode],P_URI_PASSWORD_OR_ERROR
        jmp     .loop
      .HostStarter:
        mov     [parseURImode],P_URI_HOST_OR_ERROR
        jmp     .loop

      .processDot:
        cmp     [parseURImode],0
        ja      .NotScheme
        mov     [parseURImode],P_URI_AUTORITY_OR_PATH
        jmp     .loop
      .NotScheme:
        cmp     [parseURImode],P_URI_PORT
        jne     .PrePort2
        jmp     .error
      .PrePort2:
        cmp     [parseURImode],P_URI_PASSWORD_OR_PORT
        je      .EnsurePass
        jmp     .loop

      .processSlash:
        cmp     [parseURImode],P_URI_PASSWORD_OR_ERROR
        jne     .SlashNotPassError
        jmp     .error
      .SlashNotPassError:
        cmp     [parseURImode],P_URI_PATH_OR_DOCUMENT
        jb      .ToPass
        jmp     .Pass
      .ToPass:
        dec     esi
        mov     [edi+URIstruct.FirstPathDelimiterPos], esi
        inc     esi
        mov     [parseURImode],P_URI_PATH_OR_DOCUMENT
        jmp     .loop
      .Pass:
        cmp     [parseURImode],P_URI_PARAMS
        jb      .nextSlash
        jmp     .loop
      .nextSlash:
        dec     esi
        mov     [edi+URIstruct.LastPathDelimiterPos], esi
        inc     esi
        mov     [parseURImode],P_URI_PATH_OR_DOCUMENT
        jmp     .loop







      .unsafeSym:
        cmp     [parseURImode],P_URI_PATH_OR_ERROR
        ja      .loop
        jmp     .error

      .cmpALPHA:
        cmp     al,'@'
        je      .processCat
        jb      .cmpDIGIT
        cmp     al,'Z'
        ja      .nextALPHA
        jmp     .loopALPHA
      .nextALPHA:
        cmp     al,'a'
        jb      .cmpUNDER
        cmp     al,'z'
        ja      .unsafeSym
        jmp     .loopALPHA
      .cmpUNDER:
        cmp     al,'_'
        jne     .unsafeSym
        jmp     .loopALPHA

      .cmpDIGIT:
        cmp     al,'0'
        jb      .cmpSPACE
        cmp     al,':'
        je      .processColon
        ja      .cmpQUERY
        jmp     .loopALPHA

      .cmpSPACE:
        cmp     al, ' '
        je      .processSpace
        ja      .cmpSPACE.locret
        jmp     .error
      .processSpace:
        mov     eax, [parseURImode]
        jmp     [.processSpace.Table+eax*4]
      .cmpSPACE.locret:
        ret


      .cmpMINUS:
        cmp     al,'-'
        je      .processMinus
        ja      .cmpSLASH
        jmp     .validateModeParamAndBookmark
      .processMinus:
        mov     eax, [parseURImode]
        jmp     [.processMinus.Table+eax*4]


      .cmpSLASH:
        cmp     al,'/'
        je      .processSlash
      .processSlash:
        cmp     byte[esi], al
        mov     eax, [parseURImode]
        jnz     .skipDblSlashMatch
        cmp     eax,P_URI_DBLSLASH_OR_PATH
        jnz     .skipDblSlashMatch
        dec     esi
        mov     [edi+URIstruct.DblSlashTokenPos],esi
        inc     esi
      .skipDblSlashMatch:
        jmp     [.processSlash.Table+eax*4]

        cmp     al,'0'
        jb      .cmpSPACE
        cmp     al,':'
        ja      .nextALPHA
        jb      .loop
        je      .processColon

        cmp     al,'@'
        jb      .cmpQUERY
        je      .processCat


      .cmpCOLON:
        cmp     al,':'
        je      .processColon
        ja      .cmpQUERY
        cmp     [parseURImode],P_URI_DBLSLASH_OR_PATH
        je      .processDot
        jmp     .loop
      .processColon:
        mov     eax, [parseURImode]
        jmp     [.processColon.Table+eax*4]





      .cmpCAT:
        cmp     al,'@'
        je      .processCat
        ja      .cmpLETTERS
        jmp     .validateModeParamAndBookmark


      .cmpLETTERS:
        cmp     al,'Z'
        ja      .cmpSmallLETTERS
        jmp     .loop
      .processCat:
        mov     eax, [parseURImode]
        jmp     [.processCat.Table+eax*4]


        cmp     [parseURImode],P_URI_DBLSLASH_OR_PATH
        ja      .skipClearOfFalsePositives
        xor     eax,eax
        mov     [ebp+URI.SchemeTokenPos], eax
        mov     [ebp+URI.DblSlashTokenPos], eax
        jmp     .loop

        cmp     al, '@'
        je      .catFound
        ja      .processLetters
        cmp     al, '.'
        jb      .maybBookmark
        xlatb
        test    al,[parseURImode]
      .validateModeParamAndBookmark:
        cmp     [parseURImode],P_URI_PARAMS
        jb      .error
        jmp     .loop

      .cmpALPHA.digit:
        cmp     al, '0'
        jb      .cmpALPHA.locret
        cmp     al, '9'
        ja      .cmpALPHA.locret
        jmp     .loopALPHA
      .cmpALPHA:
        cmp     al, 'A'
        jb      .cmpALPHA.digit
        cmp     al, 'Z'
        ja      .cmpALPHA.next
        jmp     .loopALPHA
      .cmpALPHA.next:
        cmp     al, 'a'
        jb      .cmpALPHA.under
        cmp     al, 'z'
        ja      .cmpALPHA.locret
        jmp     .loopALPHA
      .cmpALPHA.under:
        cmp     al, '_'
        jnz     .cmpALPHA.locret
        jmp     .loopALPHA
      .cmpALPHA.locret
        cmp     al, '9'
        ret

      .cmpSHARP:
        cmp     al,'#'
        jne     .cmpSHARP.locret
        cmp     [edi+URIstruct.BookmarksTokenPos],0
        jnz     .loopBookmarkBody
        dec     esi
        mov     [edi+URIstruct.BookmarksTokenPos],esi
        inc     esi
      .loopBookmarkBody:
        lodsb
        test    al, al
        jnz     .loopBookmarkBody
        jmp     .finish
      .cmpSHARP.locret:
        ret

      .finish:
        mov     eax, [edi+URIstruct.Pchar]
        sub     esi, eax
        mov     [edi+URIstruct.Length],esi    

so, I interest what symbols could be in URI and what dont?
of course uri in unicode str not ansi (but allowed only first 127 chars subset, and even not all) so no problem to replace al by ax, and lodsb by lodsw, and '//' by '/'+'/' shl 16 - and all would be unicode.

@ have a role of user credentials and host separator, and dont correspond @ symbol itself. so @ is allowed as such separator.

Question is different can username have alphanumeric characters? user with name https or user with name http?
Post 22 Jul 2019, 12:49
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.