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

Utf8 support for the encrypted messages #69

Closed
wants to merge 9 commits into from
Closed

Utf8 support for the encrypted messages #69

wants to merge 9 commits into from

Conversation

dreamingofelectricsheep
Copy link
Member

Added code to the literal packet implementation - it should correctly convert the native javascript strings into their utf8 counterparts.

To see why it's working look here.

return decodeURIComponent(escape(s));
};

var str2bin = function(str, array_maker) {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than passing in a function to declare an array, any reason not to just pass in an array/Uint8Array result object?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think you may have misunderstood what I was saying.

I whipped this up: http://jsfiddle.net/NtRU9/ that seems like a slightly simpler way to handle it, since we're just passing str.length into the function. Is that a reasonable approach?

Sorry for taking a few days to get back to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, crap you are right of course. You see, I put the actual utf8 conversions into these methods at first - needless to say, it didn't work, since these have nothing to do with parsing text as I had soon discovered. Nevertheless, I kept thinking that we won't know the size of resulting byte array (as would be true in case of utf8 conversion) and thus kept things like this (Uint8Array has a fixed size). I'll rebase things to the newest master and fix it.

@dreamingofelectricsheep
Copy link
Member Author

The native byte arrays do not resize themselves automatically and we do not know the number of resulting bytes in advance.

@dreamingofelectricsheep
Copy link
Member Author

Alright, I've fixed these arrays and added utf8 support to the userid packet. I've been checking everything manually so far via the test/encryption.html file and things seem to be working. I have some doubts regarding the revocation code I've modified though, so I'll try to finally adding some automated tests tomorrow.

@dreamingofelectricsheep
Copy link
Member Author

Alright, I've added automatic tests and it looks like everything's working and ready for a merge.

@dreamingofelectricsheep
Copy link
Member Author

Oh, and looks like my changes to the master test file fix issue #13

* @param {String} str Any native javascript string
* @param {String} format
*/
this.set_data = function(str, format) {
Copy link
Member

Choose a reason for hiding this comment

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

Are the next few helper methods meant to be called outside of the literaldata packet? It seems like from their use we may not want to set them as this.set_data

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now there's no point in calling them from outside as write_packet() overrides all internal data anyway. In the future however, I'd like to move away from the read/write packet duo and provide another method that takes the packet's actual contents and works on them rather than throwing it away. Right now, all openpgp_packet_ classes are readonly in essence.

@seancolyer
Copy link
Member

I made a couple of small notes, but looking good generally. I'm not usually much of a stickler for commit log but would you mind squashing commits before we merge, a number of the commits change things changed in previous commits and your initial commits were by a "Bob" character which I'm assuming is a local user.

Unrelated to your code, but it's annoying that registering the resources/openpgp*js files as binary in gitattributes works with git but github still shows the full diff for those files. Anyone know of a way to fix this?

*/
this.set_data = function(str, format) {
this.format = format;
this.data = str
Copy link
Member

Choose a reason for hiding this comment

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

I tend to be a proponent of terminating semicolons, and our codebase is generally pretty consistent about using them. I'm not a fan of syntactical religious battles but I think we would generally like to be consistent.

I'm open to other opinions.

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.

3 participants