Please see the patch below.
My use-case / intention for this patch:
Using a custom field as link title is featured by setting the link title to static and use tokens. If there is no result for these tokens (due to empty fields), token_replace() currently ignores (and spits out) the tokens.
The patch instructs token_replace() to clear tokens for which no value can be generated. So, if custom fields are empty and result to an empty link title, the Link module will again be able to use the URL as default value.
I've added the clear-flag for link title and title attribute only, because for the URL it is important the user is aware of some missing values and should see the raw tokens.