Permalink
Browse files

Fix a bug in POParser#_detectCharset extracting the charset from .po …

…headers. String#match on a substring needs to by incremented by the starting position or the entire header block is not captured. This causes unpredicable failure depending on how many lines the header block has and where within the header block the "charset" string is; it might be within the part captured or it might not.
  • Loading branch information...
1 parent ae8caa3 commit f5416e2ab81566e03500a5cc2e559971cf0be5cb @danmactough danmactough committed Oct 12, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/poparser.js
View
@@ -32,7 +32,7 @@ POParser.prototype._detectCharset = function(){
pos, headers = str, charset = "iso-8859-1", match;
if((pos = str.search(/^\s*msgid/im))>=0){
- if((pos = str.substr(pos+5).search(/^\s*(msgid|msgctxt)/im))){
+ if((pos = pos+str.substr(pos+5).search(/^\s*(msgid|msgctxt)/im))){
headers = str.substr(0, pos);
}
}

0 comments on commit f5416e2

Please sign in to comment.