koushikt / gmail-delay-send

Automatically exported from code.google.com/p/gmail-delay-send
0 stars 0 forks source link

Unexpected parsing error #85

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?*
1. Compose a new email with subject "Test -- 2013-07-03 10:43" (without quotes) 
2. Add the label DELAY_SEND.
3. Close the compose window.
4. Assert that the message is included in the Draft folder with the DELAY_SEND 
label.

*What is the expected output?*
On Wednesday July 3rd at 10.43 a.m. I expect this message to be send.

*What do you see instead?*
I receive the following error in my mailbox:
Sorry! There was an error parsing your message with subject: 'Test -- 
2013-07-03 10:43'.
The reason for this error was: 'Subject: Test -- 2013-07-03 10:43 did not 
match.'. 

*What version of the product are you using?*
Gmail delay send 0.7.7.

*Please provide any additional information below.*
If I open the Gmail_Delay_Send_0.7.7 spreadshit there is this cell in C13 where 
one can practice whether the date can be parsed. If I enter "2013-07-03 10:43" 
(without quotes) it says: 
"'2013-07-03 10:43' would be sent at 'Wed Jul 03 2013 10:43:00 GMT+0200 
(CEST)'", which is expected. So why won't it send my mail at that time?

Original issue reported on code.google.com by guillaum...@gmail.com on 3 Jul 2013 at 8:50

GoogleCodeExporter commented 9 years ago
Hello guillaumehanique,

This is pretty strange. 

Could you try a subject like: 'hello -- now'

Also, your delimiter hasn't been changed from '--'?

Original comment by blairk...@gmail.com on 3 Jul 2013 at 10:24

GoogleCodeExporter commented 9 years ago
Thank you for your reply. Other subjects work just fine. (If the delimiter
had changed I wouldn't have received an error email). I think something is
wrong with the regexp that parses the subject.

Are there unit tests for gmail delay send? (Perhaps I can have a look).

Original comment by guillaum...@gmail.com on 4 Jul 2013 at 5:00

GoogleCodeExporter commented 9 years ago
I wish there were unit tests  :-(

Google scripts API doesn't have a good unit test framework (I think somebody is 
working on one now though).

The regex is here (for 0.7.7): 
https://code.google.com/p/gmail-delay-send/source/browse/src/downloaded/GmailDel
aySend.js#420

A quick test seems to work:
(/-- [^--]/i).test("Test -- 2013-07-03 10:43")

Error case is here: 
https://code.google.com/p/gmail-delay-send/source/browse/src/downloaded/GmailDel
aySend.js#108

Just a note about the delim.. If you require a label on your emails and an 
email if found with that label but without the delimiter then you could get an 
error email w/o the correct delim.  Doesn't sound like that is the case, but 
it's something to look out for.

Let me know whatcha find!

(BTW: Family just had a new baby so might be late in response) :-)

Original comment by blairk...@gmail.com on 5 Jul 2013 at 9:19

GoogleCodeExporter commented 9 years ago
Congratulations on your new baby! Boy or a girl?

*Problem Description*
I think I already see the problem.
DELAY_SEND_REGEX = new RegExp(DELIMITER+" [^"+DELIMITER+"]+$","i");

If the delimeter is "--", which is the default, then the regular expression
will be:
--[^--]+$
or, in plain English:
- two dashes
- followed by a character that is not *a dash or a dash* more than one time
- until the end of the string.

So if we parse "Test -- 2013-07-03 10:43":
- two dashes: check: --
- followed by a character that is not a dash or a dash more than one time:
(space)2013
- (the dash between 2013 and 07 IS a dash (or a dash), so this doesn't
match).
- followed by the end of a string: NO. "(space)2013" is followed by a dash,
not by the end of the string.
Or, in other words: indeed "Test -- 2013-07-03 10:43" does NOT match the
regular expression.

*Solutions*
1 is a workaround.
3 is the best solution, I think.

1. Simply change the delimiter.
Two underscores would fix it, I think.

2. Group the delimiter.
The reason why it fails now, is because "[^--]" means: the character cannot
be a dash and it cannot be a dash. So one dash also meets this criteria.
Without testing I think that if
DELAY_SEND_REGEX = new RegExp(DELIMITER+" [^"+DELIMITER+"]+$","i"); /* is
replaced with */
DELAY_SEND_REGEX = new RegExp(DELIMITER+" [^("+DELIMITER+"]+)$","i"); /* it
might also work. */

3. Just start matching from the delimiter to the end of the string
The whole idea of the delimiter is that you choose something that does not
normally appear in the text, or, in other words, that it only appears once.
If that is true, then there is no reason to check for characters that do
NOT match the delimiter. So instead of
DELAY_SEND_REGEX = new RegExp(DELIMITER+" [^"+DELIMITER+"]+$","i"); /* one
could have */
DELAY_SEND_REGEX = new RegExp(DELIMITER+" .+$","i");  /* I see no real
reason why to explicitly match till the end of the string so */
DELAY_SEND_REGEX = new RegExp(DELIMITER+" .+","i");  /* might also work. */

Original comment by guillaum...@gmail.com on 5 Jul 2013 at 9:48

GoogleCodeExporter commented 9 years ago
Ah.. I had forgotten the [] is a character class (eg. OR'ing)

Thanks for the work debugging!

Maybe I should have just mentioned this at the beginning, but there is a new 
version of the script out which has a lot of bug fixes: 
https://code.google.com/p/gmail-delay-send/wiki/GmailDelaySendTransition_8

If you wouldn't mind giving this version a shot I'm trying to faze out 0.7.7..

New version's regexs: 
https://code.google.com/p/gmail-delay-send/source/browse/v2/src/Prefs#81 && 
https://code.google.com/p/gmail-delay-send/source/browse/v2/src/Prefs#89

BTW: Girl!  :-)

-Blair

Original comment by blairk...@gmail.com on 7 Jul 2013 at 2:02