The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,425 other followers

Using Windows API function MoveFile to check if a filename is valid…  – via Stack Overflow

Posted by jpluimers on 2018/10/17

This has a really neat Windows API trick [WayBackdelphi – How can I sanitize a string for use as a filename? – Stack Overflow by [WayBack] Alex.

Via: [WayBack] Interesting use of MoveFile, with NIL as the first parameter. https://stackoverflow.com/a/961500/49925 – Thomas Mueller (dummzeuch) – Google+

  function IsValidFilePath(const FileName: String): Boolean;
  var
    S: String;
    I: Integer;
  begin
    Result := False;
    S := FileName;
    repeat
      I := LastDelimiter('\/', S);
      MoveFile(nil, PChar(S));
      if (GetLastError = ERROR_ALREADY_EXISTS) or
         (
           (GetFileAttributes(PChar(Copy(S, I + 1, MaxInt))) = INVALID_FILE_ATTRIBUTES)
           and
           (GetLastError=ERROR_INVALID_NAME)
         ) then
        Exit;
      if I>0 then
        S := Copy(S,1,I-1);
    until I = 0;
    Result := True;
  end;

–jeroen

Posted in Delphi, Development, Software Development, Windows Development | Leave a Comment »

The part before the @ in email addresses is case sensitive

Posted by jpluimers on 2018/10/16

At [WayBackError when trying to signup using an email address with uppercase letters (#27898) · Issues · GitLab.org / GitLab Community Edition · GitLab, I commented this:

Both the :e-mail and :email_confirmation fields should get the same case processing treatment.

That treatment should consist of this:

  1. The part before the @ should be treated as case sensitive
  2. The part after the @ should be treated as case insensitive

This means that:

  • Foo@Example.Org and Foo@example.org are the same
  • Foo@example.org and foo@example.org are different

The main reason is that there are email systems expecting case sensitivity in the part before the @ sign.

I think excluding those users from being able to use GitLab is a bad idea.

See especially the comments at the Stack Overflow answer to Are email addresses case sensitive?

Relevant RFC 5321: Simple Mail Transfer Protocol sections:

Important comments:

I work at a large company and there is another person with the same first and last name. I discovered today that his local-part differs from mine only in capitalization. This has been working properly, so I was surprised to see “no widely used mail systems distinguish different addresses based on case”. We use MS Exchange which I would call “widely used”. – Matthew James Briggs Nov 24 ’15 at 20:14

RFC 5321 2.4. General Syntax Principles and Transaction Model – SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user “smith” is different from the user “Smith”. Mailbox domains follow normal DNS rules and are hence not case sensitive. – Adam111p Apr 27 ’16 at 10:02

Most important parts of the answer:

From RFC 5321, section-2.3.11:

The standard mailbox naming convention is defined to be “local-part@domaiN“; contemporary usage permits a much broader set of applications than simple “user names”. Consequently, and due to a long history of problems when intermediate hosts have attempted to optimize transport by modifying them, the local-part MUST be interpreted and assigned semantics only by the host specified in the domain part of the address.

So yes, the part before the “@” could be case-sensitive, since it is entirely under the control of the host system. In practice though, no widely used mail systems distinguish different addresses based on case.

The part after the @ sign however is the domain and according to RFC 1035, section 3.1,

“Name servers and resolvers must compare [domains] in a case-insensitive manner”

 –jeroen

Posted in Communications Development, Development, Internet protocol suite, SMTP, Software Development | Leave a Comment »

Delphi Unit Dependency Scanner

Posted by jpluimers on 2018/10/16

[WayBackDelphi Unit Dependency Scanner with sources at [WayBack] GitHub – norgepaul/DUDS

via:

Future idea: use Delphi AST as parser instead of the current internal tokeniser/parser combination.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Quickly finding and debugging jQuery event handlers with findHandlersJS – The Blinking Caret

Posted by jpluimers on 2018/10/16

tl;dr: Finding event handlers registered using jQuery can be tricky. findHandlersJS makes finding them easy, all you need is the event type and a jQuery selector for the elements where the events might originate.

I need to invest some time in using this: [WayBackQuickly finding and debugging jQuery event handlers with findHandlersJS – The Blinking Caret

Sourcecode: [WayBackraw.githubusercontent.com/ruidfigueiredo/findHandlersJS/master/findEventHandlers.js

References:

Via: [WayBackjavascript – Chrome Dev Tools : view all event listeners used in the page – Stack Overflow

–jeroen

Posted in Software Development, Development, Google, Scripting, JavaScript/ECMAScript, Chrome | Leave a Comment »

macOS Sierra: Change the order of the network ports your computer uses to connect

Posted by jpluimers on 2018/10/15

Very useful when you want to give your WiFi less priority than an USB or Thunderbolt network adapter: [WayBack] macOS Sierra: Change the order of the network ports your computer uses to connect.

It is not just that the topmost adapter gets more priority: it also determines the DNS search!

Anyway: after choosing “Set Service Order” on the right, choose the order as seen below.

–jeroen

PS: Since Apple is cleaning up their site, only the above WayBack works, but luckily the below link explains it in a very similar way when using Locations:

[WayBack] How to use network locations on your Mac – Apple Support

 

 

Posted in Apple, iMac, Mac, Mac OS X / OS X / MacOS, MacBook, Power User | Leave a Comment »

 
%d bloggers like this: