Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
727
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte - npm Package Compare versions

Comparing version 4.2.18 to 4.2.19

src/shared/utils/escape.js

2

package.json
{
"name": "svelte",
"version": "4.2.18",
"version": "4.2.19",
"description": "Cybernetically enhanced web apps",

@@ -5,0 +5,0 @@ "type": "module",

import { string_literal } from '../../../utils/stringify.js';
import { x } from 'code-red';
import { regex_double_quotes } from '../../../../utils/patterns.js';
import { escape } from '../../../../../shared/utils/escape.js';

@@ -40,5 +40,3 @@ /**

return chunk.type === 'Text'
? /** @type {import('estree').Expression} */ (
string_literal(chunk.data.replace(regex_double_quotes, '"'))
)
? /** @type {import('estree').Expression} */ (string_literal(escape(chunk.data, true)))
: x`@escape(${chunk.node}, ${is_textarea_value ? 'false' : 'true'})`;

@@ -45,0 +43,0 @@ })

@@ -5,3 +5,5 @@ import { set_current_component, current_component } from './lifecycle.js';

import { ensure_array_like } from './each.js';
import { escape } from '../../shared/utils/escape.js';
export { is_void } from '../../shared/utils/names.js';
export { escape };

@@ -71,26 +73,2 @@ export const invalid_attribute_name_character =

const ATTR_REGEX = /[&"]/g;
const CONTENT_REGEX = /[&<]/g;
/**
* Note: this method is performance sensitive and has been optimized
* https://github.com/sveltejs/svelte/pull/5701
* @param {unknown} value
* @returns {string}
*/
export function escape(value, is_attr = false) {
const str = String(value);
const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
pattern.lastIndex = 0;
let escaped = '';
let last = 0;
while (pattern.test(str)) {
const i = pattern.lastIndex - 1;
const ch = str[i];
escaped += str.substring(last, i) + (ch === '&' ? '&amp;' : ch === '"' ? '&quot;' : '&lt;');
last = i + 1;
}
return escaped + str.substring(last);
}
export function escape_attribute_value(value) {

@@ -97,0 +75,0 @@ // keep booleans, null, and undefined for the sake of `spread`

@@ -9,3 +9,3 @@ // generated during release, do not modify

*/
export const VERSION = '4.2.18';
export const VERSION = '4.2.19';
export const PUBLIC_VERSION = '4';

@@ -246,4 +246,4 @@ /// <reference lib="dom" />

'svelte:fragment': { slot?: string };
'svelte:options': HTMLProps<'svelte:options', HTMLAttributes>;
'svelte:head': { [name: string]: any };
// don't type svelte:options, it would override the types in svelte/elements and it isn't extendable anyway

@@ -250,0 +250,0 @@ [name: string]: { [name: string]: any };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc