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

Question: How to escape a cr/lf character for browser type custom actions #34

Closed
DoGauss opened this issue Jul 25, 2013 · 5 comments
Closed

Comments

@DoGauss
Copy link

DoGauss commented Jul 25, 2013

Hello Henri,

normally one would escape an carriage return or line feed charater in URLs with %0d (ascii(13)) or %0a (ascii(10)) respectively.
Unfortunately that doesn't seem to work on browser type custom actions - at least on Windows with the current version 0.9.10.

The following example action does create a new email - to and subject fields are also correct, but the mail body is just the literal string "Bitte ein Ticket erstellen und bearbeiten.%0d%0aGruß Dominik"

Is this a bug or do I have to excape a new line differently? Sorry for asking stupid questions, but Google was not a friend of mine on this one yet...

Thanks
Dom

[action_Email to servicedesk]
filter_target_service = True
leave_popwin_open = False
name = Email an Helpdesk
re_status_information_enabled = False
os =
description = Sendet eine Email an den Helpdesk
enabled = True
filter_target_host = True
re_status_information_pattern =
version = 1
re_host_reverse = False
re_status_information_reverse = False
re_service_reverse = False
re_service_enabled = False
re_host_pattern =
re_host_enabled = False
re_service_pattern =
type = browser
close_popwin = True
string = mailto:servicedesk@my.org&subject=Nagios Meldung: $HOST$ - $SERVICE$ - $STATUS-INFO$&body=Bitte ein Ticket erstellen und bearbeiten.%0d%0aGruß Dominik

@HenriWahl
Copy link
Owner

Does it work without that escapes? Is the result the same with different browsers?

@DoGauss
Copy link
Author

DoGauss commented Jul 25, 2013

I've tested it with every browser at my disposal: IE10, FF22, Chrome 22, opera 12
they all work as I'd expect it: %0d%0a causes a new line in the mail body.

It seem as if nagstamon would prevent the correct parsing of the escape sequences.
If I had to make an educated guess, I'd say the complete action string get's URL encoded before execution and thus breaking the ability to use escape sequences - that would mean: no chance of having new lines in emails.

of course: creating emails this way without new lines works just fine

@HenriWahl
Copy link
Owner

I played with your example and found it not working with &subject but ?subject.

Line 651-656 in Actions.py:

def _URLify(self, string):
    """
    return a string that fulfills requirements for URL
    exclude several chars
    """
    return urllib.quote(string, ":/=?&@")

So yes URLs get cleaned.

I tested Browser URLs without that _URLify() and it works as you expected. Obviously the browsers could URLify the URLS themselves and this method should not be needed here.

@DoGauss
Copy link
Author

DoGauss commented Jul 25, 2013

Thanks for clarifying.

nonetheless thanks for pointing out a syntactical error. the mailto protocol expects a question mark as separator between the first argument (most often the to field) and other arguments. additional parameters are linked with an ampersand.

@HenriWahl
Copy link
Owner

I think your way to send emails should work in future version - next github commit to be exact.

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

No branches or pull requests

2 participants