[Pkg-mozext-commits] [automatic-save-folder] 34/133: Fix : - Prevent ASF to store the current domain as a temporary data while in private browsing mode. - Corrected the group capture using parenthesis and rename the dropdown suggested path list accordingly for the current filter.

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:49 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch wip
in repository automatic-save-folder.

commit 1845745b97f11aac5f367d380420ef8d50cbcdf7
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Sat Nov 14 21:20:44 2009 +0000

    Fix :
      - Prevent ASF to store the current domain as a temporary data while in private
        browsing mode.
      - Corrected the group capture using parenthesis and rename the dropdown
        suggested path list accordingly for the current filter.
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@34 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf_download.js    | 115 ++++++++++++++++++++++++++-------------------
 content/asf_right_click.js | 111 ++++++++++++++++++++++++-------------------
 locale/en-US/asf.dtd       |   2 +-
 locale/fr-FR/asf.dtd       |   2 +-
 4 files changed, 131 insertions(+), 99 deletions(-)

diff --git a/content/asf_download.js b/content/asf_download.js
index ed1552e..7d30208 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -191,49 +191,34 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 		}
 		else // if a filter is found 
 		{
-			
 			var folder = filters[idx][2];
 			
-			
 			// If Advanced mode is ON, let's check the variables and create the folder
 			if (variable_mode == true) 
 			{
-
-// Ted Gifford, start block		
-			// String capture in filename with $f<1-9>
-              try {
-               //alert(file_regexp.length);
-               if (file_regexp.length > 1)
-               {
-                       //alert('munging folder: ' + folder);
-                       for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
-                               folder = folder.replace("$"+replace_index+"f", file_regexp[replace_index]);
-                       //alert('munged folder: ' + folder);
-               }
-               } catch (e) {alert(e);}
-			// String capture in domain with $d<1-9>
-			  try {
-               //alert(dom_regexp.length);
-               if (dom_regexp.length > 1)
-               {
-                       //alert('munging folder: ' + folder);
-                       for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
-                               folder = folder.replace("$"+replace_index+"d", dom_regexp[replace_index]);
-                       //alert('munged folder: ' + folder);
-               }
-               } catch (e) {alert(e);}			
-// Ted Gifford, end	block
-			
-			
-			
-				folder = this.createfolder(folder, idx);		
+				folder = this.createfolder(folder, idx);
 			}
 			
 			this.set_savepath(folder);
 		}
 		
-		// in every case, set the new file hosted domain to tempdomain
-		this.saveUnicodeString("extensions.asf.tempdomain", domain);
+		// in every case, set the new file hosted domain to tempdomain if not in private browsing
+		var inPrivateBrowsing = false;
+		if (this.firefoxversion == 3)
+		{
+			try {
+				var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+									.getService(Components.interfaces.nsIPrivateBrowsingService);
+				inPrivateBrowsing = pbs.privateBrowsingEnabled;
+			}
+			catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
+			}
+		}
+		if (!inPrivateBrowsing)
+		{
+			this.saveUnicodeString("extensions.asf.tempdomain", domain);
+		}
+		
 		
 		// Automatic saving when clicking on a link. The save dialog still flash onscreen very quickly.
 		if (dialogaccept)
@@ -360,21 +345,10 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 		// check the filter's data
 		var asf_domain = "";
 		var asf_filename = "";		
-		if (idx) {  // If a filter match, idx is true
+		if (idx)  // If a filter match, idx is true
+		{ 
 			asf_domain = this.loadUnicodeString("extensions.asf.filters"+ idx +".domain");
-			// Trim the / / if domain is regexp
-			if (this.is_regexp(asf_domain))
-			{
-				asf_domain = asf_domain.substring(1, asf_domain.length);
-				asf_domain = asf_domain.substring(0, asf_domain.length -1);
-			}
 			asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
-			// Trim the / / if filename is regexp
-			if (this.is_regexp(asf_filename))
-			{
-				asf_filename = asf_filename.substring(1, asf_filename.length);
-				asf_filename = asf_filename.substring(0, asf_filename.length -1);
-			}
 		}
 		else // no filter is found, use actual Domain and filename without extension
 		{
@@ -382,6 +356,48 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 			asf_filename = file_name;
 		}
 		
+		
+		var dom_regexp = this.test_regexp(asf_domain, document.getElementById("source").value); 
+		var file_regexp = this.test_regexp(asf_filename, filename); 
+
+// Ted Gifford, start block		
+		// String capture in filename with $<1-9>f
+		try {
+		//alert(file_regexp.length);
+			if (file_regexp.length > 1)
+			{
+				//alert('munging path: ' + path);
+				for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
+						path = path.replace("$"+replace_index+"f", file_regexp[replace_index]);
+				//alert('munged path: ' + path);
+			}
+		} catch (e) {alert(e);}
+		// String capture in domain with $<1-9>d
+		try {
+		//alert(dom_regexp.length);
+			if (dom_regexp.length > 1)
+			{
+				//alert('munging path: ' + path);
+				for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
+						path = path.replace("$"+replace_index+"d", dom_regexp[replace_index]);
+				//alert('munged path: ' + path);
+			}
+		} catch (e) {alert(e);}
+// Ted Gifford, end block
+		
+		// Trim the / / if domain is regexp
+		if (this.is_regexp(asf_domain))
+		{
+			asf_domain = asf_domain.substring(1, asf_domain.length);
+			asf_domain = asf_domain.substring(0, asf_domain.length -1);
+		}		
+		// Trim the / / if filename is regexp
+		if (this.is_regexp(asf_filename))
+		{
+			asf_filename = asf_filename.substring(1, asf_filename.length);
+			asf_filename = asf_filename.substring(0, asf_filename.length -1);
+		}
+		
 		// Check if asf_rd is present and process     asf_rd = Regexp the domain
 		if (path.search("%asf_rd%") != -1)
 		{
@@ -639,6 +655,7 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 		{
 			// read the filter number x
 			path = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
+			path = variable_mode == true? this.createfolder(path, i) : path;
 			
 			if (this.indexInArray(pathlist, path) < 0) 
 			{ 
@@ -652,7 +669,7 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 		for (var i = 0; i < pathlist.length; i++)
 		{
 			path = pathlist[i];
-			path = variable_mode == true? this.createfolder(path) : path; 
+			
 			var menuitem = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem');
 			menuitem.setAttribute('label', path);
 			menuitem.setAttribute('crop', 'center');
@@ -727,14 +744,14 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
 		if (test_regexp == false) // replace simple wildcard and special characters with corresponding regexp
 		{
 			filters = filters.replace(/\./gi, "\\.")
-													.replace(/\*/gi, "(.)*")
+													.replace(/\*/gi, ".*")
 													.replace(/\$/gi, "\\$")
 													.replace(/\^/gi, "\\^")
 													.replace(/\+/gi, "\\+")
 													.replace(/\?/gi, ".")
 													.replace(/\|/gi, "\\|")
 													.replace(/\[/gi, "\\[")
-													.replace(/\//gi,'\\/');
+													.replace(/\//gi, "\\/");
 			filters = ".*"+filters+".*";
 		}
 		else // remove the first and last slash
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 02c35ce..ed8b52b 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -411,49 +411,33 @@ var automatic_save_folder = {
 		}
 		else // if a filter is found 
 		{
-			
 			var folder = filters[idx][2];
 			
-			
 			// If Advanced mode is ON, let's check the variables and create the folder
 			if (variable_mode == true) 
 			{
-
-// Ted Gifford, start block		
-			// String capture in filename with $f<1-9>
-              try {
-               //alert(file_regexp.length);
-               if (file_regexp.length > 1)
-               {
-                       //alert('munging folder: ' + folder);
-                       for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
-                               folder = folder.replace("$"+replace_index+"f", file_regexp[replace_index]);
-                       //alert('munged folder: ' + folder);
-               }
-               } catch (e) {alert(e);}
-			// String capture in domain with $d<1-9>
-			  try {
-               //alert(dom_regexp.length);
-               if (dom_regexp.length > 1)
-               {
-                       //alert('munging folder: ' + folder);
-                       for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
-                               folder = folder.replace("$"+replace_index+"d", dom_regexp[replace_index]);
-                       //alert('munged folder: ' + folder);
-               }
-               } catch (e) {alert(e);}			
-// Ted Gifford, end	block
-			
-			
-			
-				folder = this.createfolder(aFpP, folder, idx);		
+				folder = this.createfolder(aFpP, folder, idx);
 			}
 			
 			this.set_savepath(folder);
 		}
 		
-		// in every case, set the new file hosted domain to tempdomain
-		this.saveUnicodeString("extensions.asf.tempdomain", domain);
+		// in every case, set the new file hosted domain to tempdomain if not in private browsing
+		var inPrivateBrowsing = false;
+		if (this.firefoxversion == 3)
+		{
+			try {
+				var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+									.getService(Components.interfaces.nsIPrivateBrowsingService);
+				inPrivateBrowsing = pbs.privateBrowsingEnabled;
+			}
+			catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
+			}
+		}
+		if (!inPrivateBrowsing)
+		{
+			this.saveUnicodeString("extensions.asf.tempdomain", domain);
+		}
 		
 		
 	},
@@ -569,21 +553,10 @@ var automatic_save_folder = {
 		// check the filter's data
 		var asf_domain = "";
 		var asf_filename = "";		
-		if (idx) {  // If a filter match, idx is true
+		if (idx) // If a filter match, idx is true
+		{  
 			asf_domain = this.loadUnicodeString("extensions.asf.filters"+ idx +".domain");
-			// Trim the / / if domain is regexp
-			if (this.is_regexp(asf_domain))
-			{
-				asf_domain = asf_domain.substring(1, asf_domain.length);
-				asf_domain = asf_domain.substring(0, asf_domain.length -1);
-			}
 			asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
-			// Trim the / / if filename is regexp
-			if (this.is_regexp(asf_filename))
-			{
-				asf_filename = asf_filename.substring(1, asf_filename.length);
-				asf_filename = asf_filename.substring(0, asf_filename.length -1);
-			}
 		}
 		else // no filter is found, use actual Domain and filename without extension
 		{
@@ -591,6 +564,48 @@ var automatic_save_folder = {
 			asf_filename = file_name;
 		}
 		
+		
+		var dom_regexp = this.test_regexp(asf_domain, scheme+"://"+domain); 
+		var file_regexp = this.test_regexp(asf_filename, filename); 
+
+// Ted Gifford, start block		
+		// String capture in filename with $<1-9>f
+		try {
+		//alert(file_regexp.length);
+			if (file_regexp.length > 1)
+			{
+				//alert('munging path: ' + path);
+				for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
+						path = path.replace("$"+replace_index+"f", file_regexp[replace_index]);
+				//alert('munged path: ' + path);
+			}
+		} catch (e) {alert(e);}
+		// String capture in domain with $<1-9>d
+		try {
+		//alert(dom_regexp.length);
+			if (dom_regexp.length > 1)
+			{
+				//alert('munging path: ' + path);
+				for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
+						path = path.replace("$"+replace_index+"d", dom_regexp[replace_index]);
+				//alert('munged path: ' + path);
+			}
+		} catch (e) {alert(e);}
+// Ted Gifford, end block
+		
+		// Trim the / / if domain is regexp
+		if (this.is_regexp(asf_domain))
+		{
+			asf_domain = asf_domain.substring(1, asf_domain.length);
+			asf_domain = asf_domain.substring(0, asf_domain.length -1);
+		}		
+		// Trim the / / if filename is regexp
+		if (this.is_regexp(asf_filename))
+		{
+			asf_filename = asf_filename.substring(1, asf_filename.length);
+			asf_filename = asf_filename.substring(0, asf_filename.length -1);
+		}		
+		
 		// Check if asf_rd is present and process     asf_rd = Regexp the domain
 		if (path.search("%asf_rd%") != -1)
 		{
@@ -768,14 +783,14 @@ var automatic_save_folder = {
 		if (test_regexp == false) // replace simple wildcard and special characters with corresponding regexp
 		{
 			filters = filters.replace(/\./gi, "\\.")
-													.replace(/\*/gi, "(.)*")
+													.replace(/\*/gi, ".*")
 													.replace(/\$/gi, "\\$")
 													.replace(/\^/gi, "\\^")
 													.replace(/\+/gi, "\\+")
 													.replace(/\?/gi, ".")
 													.replace(/\|/gi, "\\|")
 													.replace(/\[/gi, "\\[")
-													.replace(/\//gi,'\\/');
+													.replace(/\//gi, "\\/");
 			filters = ".*"+filters+".*";
 		}
 		else // remove the first and last slash
diff --git a/locale/en-US/asf.dtd b/locale/en-US/asf.dtd
index 8d4ea9e..725d3e2 100644
--- a/locale/en-US/asf.dtd
+++ b/locale/en-US/asf.dtd
@@ -58,7 +58,7 @@
 <!ENTITY asf.dynamics.label "Dynamic folders">
 <!ENTITY asf.variablemode.bool "Enable">
 <!ENTITY asf.variablemode.tooltip1 "Allow you to edit the filters saving path manually and add dynamic variables, like the date of the day or the file name.">
-<!ENTITY asf.variablemode.tooltip2 "Attention: When Firefox is in private browsing mode, non existent dynamic folders will not be created. The last valid folder will be used instead.">
+<!ENTITY asf.variablemode.tooltip2 "Attention: If you are in private browsing mode, Firefox will not create the folder if it doesn't exist yet. The suggested folder will be the last used in non private browsing.">
 <!ENTITY asf.variablemode.label "Attention : Uppercase and lowercase tags are different.">
 <!ENTITY asf.variables.label "Tags list :">
 
diff --git a/locale/fr-FR/asf.dtd b/locale/fr-FR/asf.dtd
index 0ef8dd7..8146c5a 100644
--- a/locale/fr-FR/asf.dtd
+++ b/locale/fr-FR/asf.dtd
@@ -58,7 +58,7 @@
 <!ENTITY asf.dynamics.label "Dossiers dynamiques">
 <!ENTITY asf.variablemode.bool "Activer">
 <!ENTITY asf.variablemode.tooltip1 "Permet d'éditer manuellement le chemin d'enregistrement des filtres et d'ajouter des variables dynamiques, comme la date du jour ou le domaine d'hébergement.">
-<!ENTITY asf.variablemode.tooltip2 "Attention : Lorsque Firefox utilise la navigation privée, les dossiers dynamiques inexistant ne seront pas créés. Le dernier dossier valide sera proposé à la place.">
+<!ENTITY asf.variablemode.tooltip2 "Attention : Lorsque vous utilisez la navigation privée, Firefox ne vous proposera pas les dossiers inexistant. Le dernier dossier utilisé en mode non privé sera proposé à la place.">
 <!ENTITY asf.variablemode.label "Attention : Les majuscules et les minuscules correspondent à des balises différentes.">
 <!ENTITY asf.variables.label "Liste des balises :">
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/automatic-save-folder.git



More information about the Pkg-mozext-commits mailing list