MCPcopy Index your code
hub / github.com/ether/etherpad / stripRemoteImages

Function stripRemoteImages

src/node/utils/ExportSanitizeHtml.ts:179–215  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

177]);
178
179export const stripRemoteImages = (html: string): string => {
180 let out = '';
181 const parser = new Parser({
182 onopentag(name, attribs) {
183 if (name === 'img') {
184 const src = attribs.src || '';
185 if (isLocalSrc(src)) {
186 let tag = '<img';
187 for (const [k, v] of Object.entries(attribs)) {
188 tag += ` ${k}="${escapeAttr(v)}"`;
189 }
190 tag += '>';
191 out += tag;
192 } else {
193 out += escapeText(attribs.alt || '');
194 }
195 return;
196 }
197 let tag = `<${name}`;
198 for (const [k, v] of Object.entries(attribs)) {
199 tag += ` ${k}="${escapeAttr(v)}"`;
200 }
201 tag += '>';
202 out += tag;
203 },
204 ontext(text) {
205 out += text;
206 },
207 onclosetag(name) {
208 if (VOID_TAGS.has(name)) return;
209 out += `</${name}>`;
210 },
211 }, {decodeEntities: false, lowerCaseTags: true});
212 parser.write(html);
213 parser.end();
214 return out;
215};

Callers 2

export.tsFile · 0.85
ExportHandler.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected