зеркало из https://github.com/mozilla/gecko-dev.git
Fixed editor bugs 68064 and 70263. r=brade, sr=kin
This commit is contained in:
Родитель
6f1d34ff6b
Коммит
a77f7a0332
|
@ -218,10 +218,11 @@ function ReplaceWhitespace(string, charReplace) {
|
|||
return string.replace(/(^\s+)|(\s+$)/g,'').replace(/\s+/g,charReplace)
|
||||
}
|
||||
|
||||
// Replace whitespace with "_" and allow only "word" characters (a-z,A-Z,0-9 and _)
|
||||
function PrepareStringForURL(string)
|
||||
// Replace whitespace with "_" and allow only HTML CDATA
|
||||
// characters: "a"-"z","A"-"Z","0"-"9", "_", ":", "-", and "."
|
||||
function ConvertToCDATAString(string)
|
||||
{
|
||||
return ReplaceWhitespace(string,"_").replace(/\W+/g,'');
|
||||
return ReplaceWhitespace(string,"_").replace(/[^a-zA-Z0-9_\.\-\:]+/g,'');
|
||||
}
|
||||
|
||||
// this function takes an elementID and a flag
|
||||
|
|
|
@ -288,7 +288,7 @@ function FillListboxes()
|
|||
{
|
||||
// Use just first 40 characters, don't add "...",
|
||||
// and replace whitespace with "_" and strip non-word characters
|
||||
text = PrepareStringForURL(TruncateStringAtWordEnd(text, 40, false));
|
||||
text = ConvertToCDATAString(TruncateStringAtWordEnd(text, 40, false));
|
||||
// Append "_" to any name already in the list
|
||||
if (GetExistingHeadingIndex(text) > -1)
|
||||
text += "_";
|
||||
|
@ -327,12 +327,16 @@ function ChangeText()
|
|||
}
|
||||
}
|
||||
|
||||
var gClearListSelections = true;
|
||||
|
||||
function ChangeLocation()
|
||||
{
|
||||
if (gClearListSelections)
|
||||
{
|
||||
// Unselect the treelists
|
||||
UnselectNamedAnchor();
|
||||
UnselectHeadings();
|
||||
|
||||
}
|
||||
// Set OK button enable state
|
||||
ChangeText();
|
||||
}
|
||||
|
@ -354,8 +358,11 @@ function SelectNamedAnchor()
|
|||
{
|
||||
if (haveNamedAnchors)
|
||||
{
|
||||
// Prevent ChangeLocation() from unselecting the list
|
||||
gClearListSelections = false;
|
||||
dialog.hrefInput.value = "#"+GetSelectedTreelistValue(dialog.NamedAnchorList);
|
||||
ChangeText();
|
||||
gClearListSelections = true;
|
||||
//ChangeText();
|
||||
}
|
||||
else
|
||||
UnselectNamedAnchor();
|
||||
|
@ -370,8 +377,9 @@ function SelectHeading()
|
|||
{
|
||||
if (haveHeadings)
|
||||
{
|
||||
gClearListSelections = false;
|
||||
dialog.hrefInput.value = "#"+GetSelectedTreelistValue(dialog.HeadingsList);
|
||||
ChangeText();
|
||||
gClearListSelections = true;
|
||||
}
|
||||
else
|
||||
UnselectHeadings();
|
||||
|
|
|
@ -56,7 +56,7 @@ function Startup()
|
|||
var name = GetSelectionAsText();
|
||||
// Get 40 characters of the selected text and don't add "...",
|
||||
// replace whitespace with "_" and strip non-word characters
|
||||
name = PrepareStringForURL(TruncateStringAtWordEnd(name, 40, false));
|
||||
name = ConvertToCDATAString(TruncateStringAtWordEnd(name, 40, false));
|
||||
//Be sure the name is unique to the document
|
||||
if (AnchorNameExists(name))
|
||||
name += "_"
|
||||
|
@ -90,7 +90,7 @@ function ChangeName()
|
|||
// Replace spaces with "_" and strip other non-URL characters
|
||||
// Note: we could use ConvertAndEscape, but then we'd
|
||||
// have to UnEscapeAndConvert beforehand - too messy!
|
||||
nameInput.value = PrepareStringForURL(nameInput.value.replace(/\s+/g, "_"));
|
||||
nameInput.value = ConvertToCDATAString(nameInput.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ function ValidateData()
|
|||
// Replace spaces with "_" and strip other characters
|
||||
// Note: we could use ConvertAndEscape, but then we'd
|
||||
// have to UnConverAndEscape beforehand - too messy!
|
||||
name = PrepareStringForURL(name);
|
||||
name = ConvertToCDATAString(name);
|
||||
|
||||
if (originalName != name && AnchorNameExists(name))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче