jdev - 2024-03-01


  1. MSavoritias (fae,ve)

    reading https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 which says: localpart = 1*1023(userbyte) ; ; a "userbyte" is a byte used to represent a ; UTF-8 encoded Unicode code point that can be ; contained in a string that conforms to the ; UsernameCaseMapped profile of the PRECIS ; IdentifierClass defined in RFC 7613 does "a "userbyte" is a byte used to represent a UTF-8 encoded Unicode code point that can be contained in a string" mean that it can be 1023 letters or because unicode can have more than one codepoint per letter sometimes it means codepoint is depending on language?

  2. MSavoritias (fae,ve)

    or should i look at precis?

  3. MSavoritias (fae,ve)

    my usecase is i want to write a very crude regex to see if a string matches a jid. so i wonder if it can be based on reality in an afternoon or not :P

  4. MSavoritias (fae,ve)

    regex as in https://docs.python.org/3/library/re.html#re.fullmatch

  5. MSavoritias (fae,ve)

    my line of code is literally: `input_xid = re.fullmatch("", str(event["xid"]))`

  6. MSavoritias (fae,ve)

    the regex is going to be inside the quotes

  7. lovetox

    use a simple regex that matches @ and be done with it?

  8. lovetox

    you want to match a jid, or you want to validate if some string is a valid jid?

  9. lovetox

    validating seems hard with regex, and not sure if you really need that

  10. MSavoritias (fae,ve)

    > you want to match a jid, or you want to validate if some string is a valid jid? if some string is valid

  11. MSavoritias (fae,ve)

    > you want to match a jid, or you want to validate if some string is a valid jid? if some string is valid as a jid

  12. lovetox

    yeah im going with its impossible with regex, dont waste your time

  13. MSavoritias (fae,ve)

    i basically just did: `matched_xid = re.fullmatch(r"\S{21}@\S{6}.\S{3}", str(event["xid"]))`

  14. MSavoritias (fae,ve)

    ah thats what i thought yeah

  15. MSavoritias (fae,ve)

    oh well its not a "real" program anyway. so this should be good

  16. lovetox

    its probably easier to match simply with @ to filter down the possible strings

  17. lovetox

    then pass that to a dedicated validation function

  18. lovetox

    you can copy these from the various xmpp libs

  19. MSavoritias (fae,ve)

    wait what would a dedicated validation function be? checking if its html or something?

  20. MSavoritias (fae,ve) goes to read more about python validation

  21. lovetox

    simply a function written to validate a jid according to spec

  22. lovetox

    but it has nothing to do with regex

  23. lovetox

    https://dev.gajim.org/gajim/python-nbxmpp/-/blob/master/nbxmpp/protocol.py#L641

  24. lovetox

    here for example you can copy that code

  25. lovetox

    or you look at other python libraries, like e.g. aioxmpp

  26. MSavoritias (fae,ve)

    will do. thank you!

  27. moparisthebest

    > ha i solved it even easier, i can join simply against the message table itself, no need for a second table You certainly want one self-referential table for messages and not 2 because you can have unlimited corrections, not just 1

  28. singpolyma

    > use a simple regex that matches @ and be done with it? I think you mean . jid is not required to have @ ;)

  29. Kev

    Nor is it required to have a . :)

  30. singpolyma

    Kev: shhhhh

  31. singpolyma

    on the federated network it effectively is

  32. singpolyma

    unless you own the tld

  33. moparisthebest

    If you... That was what I was asking

  34. singpolyma

    and it's not bonkers to require the trailing dot if you own the tld

  35. andermillanlopez2

    Hello! How is everything? Has anyone by any chance used stanzaJS to create a plugin? I need to send some data via XMPP without users seeing that a message was sent, since it is to perform a validation. I am starting to use the XMPP protocol.

  36. MSavoritias (fae,ve)

    reading through the gajim jid validation, is the domain converted to ascii because of punycode and such? ``` def domain_to_ascii(self) -> str: return idna2008_prep(self.domain, to_ascii=True) ```

  37. lovetox

    the way you phrased that sentence gives all the wrong impressions

  38. lovetox

    you found a utility method which is *not* part of any validation process

  39. MSavoritias (fae,ve)

    right i didnt mean to imply gajim does something wrong here

  40. MSavoritias (fae,ve)

    if that is how it appeared

  41. lovetox

    and yes, a user of the library may want to show a domain with ascii only, for example to make homoglyphs visible

  42. lovetox

    https://en.wikipedia.org/wiki/IDN_homograph_attack