Fossil SCM

Patch the javascript compressor so that it does not elide text after // if the // immediately follows a :, as that text might be part of a URI string literal.

drh 2022-07-28 18:19 trunk
Commit ffa1c7d0a0e6b32eab1a6b7f217a8f653f76fe650e80de407a15dab9dfe05c79
1 file changed +1 -1
--- tools/mkbuiltin.c
+++ tools/mkbuiltin.c
@@ -75,11 +75,11 @@
7575
static void compressJavascript(unsigned char *z, int *pn){
7676
int n = *pn;
7777
int i, j, k;
7878
for(i=j=0; i<n; i++){
7979
unsigned char c = z[i];
80
- if( c=='/' ){
80
+ if( c=='/' && (i==0 || z[i-1]!=':')){
8181
if( z[i+1]=='*' ){
8282
while( j>0 && (z[j-1]==' ' || z[j-1]=='\t') ){ j--; }
8383
for(k=i+3; k<n && (z[k]!='/' || z[k-1]!='*'); k++){}
8484
i = k;
8585
continue;
8686
--- tools/mkbuiltin.c
+++ tools/mkbuiltin.c
@@ -75,11 +75,11 @@
75 static void compressJavascript(unsigned char *z, int *pn){
76 int n = *pn;
77 int i, j, k;
78 for(i=j=0; i<n; i++){
79 unsigned char c = z[i];
80 if( c=='/' ){
81 if( z[i+1]=='*' ){
82 while( j>0 && (z[j-1]==' ' || z[j-1]=='\t') ){ j--; }
83 for(k=i+3; k<n && (z[k]!='/' || z[k-1]!='*'); k++){}
84 i = k;
85 continue;
86
--- tools/mkbuiltin.c
+++ tools/mkbuiltin.c
@@ -75,11 +75,11 @@
75 static void compressJavascript(unsigned char *z, int *pn){
76 int n = *pn;
77 int i, j, k;
78 for(i=j=0; i<n; i++){
79 unsigned char c = z[i];
80 if( c=='/' && (i==0 || z[i-1]!=':')){
81 if( z[i+1]=='*' ){
82 while( j>0 && (z[j-1]==' ' || z[j-1]=='\t') ){ j--; }
83 for(k=i+3; k<n && (z[k]!='/' || z[k-1]!='*'); k++){}
84 i = k;
85 continue;
86

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button