mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 09:24:49 +00:00
escape XML chars in title
This commit is contained in:
parent
36c9b68e10
commit
d25e851edc
3 changed files with 19 additions and 14 deletions
|
@ -167,7 +167,7 @@ function getAbsoluteUrl(urlStr) {
|
|||
} else if (urlStr.indexOf('http') !== 0) {
|
||||
absoluteUrl = currentUrl + '/' + urlStr;
|
||||
}
|
||||
absoluteUrl = escapeAmp(absoluteUrl);
|
||||
absoluteUrl = escapeXMLChars(absoluteUrl);
|
||||
return absoluteUrl;
|
||||
} catch (e) {
|
||||
console.log('Error:', e);
|
||||
|
@ -291,13 +291,18 @@ function generateRandomTag(tagLen) {
|
|||
return text;
|
||||
}
|
||||
|
||||
function escapeAmp(text) {
|
||||
var newText = text.replace(/&/ig, '&');
|
||||
newText = newText.replace(/&/ig, '&');
|
||||
return newText;
|
||||
function escapeXMLChars(text) {
|
||||
return text.replace(/&/g, '&')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function getEbookFileName(name) {
|
||||
var newName = name.replace(/&/ig, '&');
|
||||
return newName;
|
||||
return name.replace(/&/ig, '&')
|
||||
.replace(/>/ig, '')
|
||||
.replace(/</ig, '')
|
||||
.replace(/"/ig, '')
|
||||
.replace(/'/ig, '');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue