Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs and remove check we already do in check_domain ... also … #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

grosser
Copy link
Contributor

@grosser grosser commented Oct 11, 2016

/ is not supported since we check if the string starts with ':' earlier

@vmg @kivikakk

@grosser
Copy link
Contributor Author

grosser commented Oct 13, 2016

I can haz review ?

};

size_t i;

for (i = 0; i < valid_uris_count; ++i) {
size_t len = strlen(valid_uris[i]);

if (link_len > len &&
strncasecmp((char *)link, valid_uris[i], len) == 0 &&
rinku_isalnum(link[len]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to remove this in case autolink_issafe gets another consumer. As the overarching "is this safe to auto-link?" method, I'd rather leave this check in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because there is 1 alphanum character does not mean it's safe to link ... implementing partial checks in multiple places seems like a bad security model ... ideally this method would be "is_safe_protocol" ...

link->start = pos;
link->end = utf8proc_find_space(data, link->end, size);

// move to before the protocol
while (link->start && rinku_isalpha(data[link->start - 1]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these kinds of comments are helpful. (see the gist of this article)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty cryptic and took us a while to understand ... so I think having some top-level understanding of the flow makes it easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... ideally the code would be more readable ... but I was not brave enough to do that :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you could write some comments for these methods ... I'm just poking in here and trying to piece information together ...

bool
autolink_issafe(const uint8_t *link, size_t link_len)
{
static const size_t valid_uris_count = 5;
static const char *valid_uris[] = {
"/", "http://", "https://", "ftp://", "mailto:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants